/*
- * $Id: mangle.c,v 1.7 2002-06-09 07:15:44 jmarcus Exp $
+ * $Id: mangle.c,v 1.8 2002-07-04 18:14:38 jmarcus Exp $
*
* Copyright (c) 2002. Joe Marcus Clarke (marcus@marcuscom.com)
* All Rights Reserved. See COPYRIGHT.
/* First, attmept to locate a file extension. */
if ((ext = strrchr(filename, '.')) != NULL) {
ext_len = strlen(ext);
+ if (ext_len > MAX_EXT_LENGTH) {
+ /* Do some bounds checking to prevent an extension overflow. */
+ ext_len = MAX_EXT_LENGTH;
+ }
}
/* Check to see if we already have a mangled filename by this name. */
strcat(m, mangle_suffix);
if (ext) {
- strcat(m, ext);
+ strncat(m, ext, ext_len);
}
tf = cnid_mangle_get(vol->v_db, m);
/*
- * $Id: mangle.h,v 1.1 2002-05-29 18:02:59 jmarcus Exp $
+ * $Id: mangle.h,v 1.2 2002-07-04 18:14:38 jmarcus Exp $
*
*/
#define MANGLE_CHAR "~"
#define MANGLE_LENGTH 3 /* XXX This really can't be changed. */
#define MAX_MANGLE_SUFFIX_LENGTH 999
+#define MAX_EXT_LENGTH 4 /* XXX This cannot be greater than 27 */
#define MAX_LENGTH 31
extern char *mangle __P((const struct vol *, char *));