Kevin Fenzi 0f49f1
--- fontforge/fontforge/fvimportbdf.c	15 Apr 2010 10:47:36 -0000	1.58
Kevin Fenzi 0f49f1
+++ fontforge/fontforge/fvimportbdf.c	3 Dec 2010 21:03:38 -0000
Kevin Fenzi 0f49f1
@@ -560,7 +560,7 @@
Kevin Fenzi 0f49f1
 	}
Kevin Fenzi 0f49f1
     
Kevin Fenzi 0f49f1
 	if ( strcmp(tok,"FONT")==0 ) {
Kevin Fenzi 0f49f1
-	    if ( sscanf(buf,"-%*[^-]-%[^-]-%[^-]-%[^-]-%*[^-]-", family, weight, italic )!=0 ) {
Kevin Fenzi 0f49f1
+	    if ( sscanf(buf,"-%*[^-]-%99[^-]-%99[^-]-%99[^-]-%*[^-]-", family, weight, italic )!=0 ) {
Kevin Fenzi 0f49f1
 		char *pt=buf;
Kevin Fenzi 0f49f1
 		int dcnt=0;
Kevin Fenzi 0f49f1
 		while ( *pt=='-' && dcnt<7 ) { ++pt; ++dcnt; }
Kevin Fenzi 0f49f1
@@ -616,26 +616,30 @@
Kevin Fenzi 0f49f1
 	    sscanf(buf, "%d", &defs->metricsset );
Kevin Fenzi 0f49f1
 	else if ( strcmp(tok,"VVECTOR")==0 )
Kevin Fenzi 0f49f1
 	    sscanf(buf, "%*d %d", &defs->vertical_origin );
Kevin Fenzi 0f49f1
+	/* For foundry, fontname and encname, only copy up to the buffer size */
Kevin Fenzi 0f49f1
 	else if ( strcmp(tok,"FOUNDRY")==0 )
Kevin Fenzi 0f49f1
-	    sscanf(buf, "%[^\"]", foundry );
Kevin Fenzi 0f49f1
+	    sscanf(buf, "%99[^\"]", foundry );
Kevin Fenzi 0f49f1
 	else if ( strcmp(tok,"FONT_NAME")==0 )
Kevin Fenzi 0f49f1
-	    sscanf(buf, "%[^\"]", fontname );
Kevin Fenzi 0f49f1
+	    sscanf(buf, "%99[^\"]", fontname );
Kevin Fenzi 0f49f1
 	else if ( strcmp(tok,"CHARSET_REGISTRY")==0 )
Kevin Fenzi 0f49f1
-	    sscanf(buf, "%[^\"]", encname );
Kevin Fenzi 0f49f1
+	    sscanf(buf, "%99[^\"]", encname );
Kevin Fenzi 0f49f1
 	else if ( strcmp(tok,"CHARSET_ENCODING")==0 ) {
Kevin Fenzi 0f49f1
 	    enc = 0;
Kevin Fenzi 0f49f1
 	    if ( sscanf(buf, " %d", &enc )!=1 )
Kevin Fenzi 0f49f1
 		sscanf(buf, "%d", &enc );
Kevin Fenzi 0f49f1
+	/* These properties should be copied up to the buffer length too */
Kevin Fenzi 0f49f1
 	} else if ( strcmp(tok,"FAMILY_NAME")==0 ) {
Kevin Fenzi 0f49f1
-	    strcpy(family,buf);
Kevin Fenzi 0f49f1
+	    strncpy(family,buf,99);
Kevin Fenzi 0f49f1
 	} else if ( strcmp(tok,"FULL_NAME")==0 || strcmp(tok,"FACE_NAME")==0 ) {
Kevin Fenzi 0f49f1
-	    strcpy(full,buf);
Kevin Fenzi 0f49f1
+	    strncpy(full,buf,99);
Kevin Fenzi 0f49f1
 	} else if ( strcmp(tok,"WEIGHT_NAME")==0 )
Kevin Fenzi 0f49f1
-	    strcpy(weight,buf);
Kevin Fenzi 0f49f1
+	    strncpy(weight,buf,99);
Kevin Fenzi 0f49f1
 	else if ( strcmp(tok,"SLANT")==0 )
Kevin Fenzi 0f49f1
-	    strcpy(italic,buf);
Kevin Fenzi 0f49f1
+	    strncpy(italic,buf,99);
Kevin Fenzi 0f49f1
 	else if ( strcmp(tok,"COPYRIGHT")==0 ) {
Kevin Fenzi 0f49f1
-	    strcpy(comments,buf);
Kevin Fenzi 0f49f1
+		/* LS: Assume the size of the passed-in buffer is 1000, see below in
Kevin Fenzi 0f49f1
+		 * COMMENT */
Kevin Fenzi 0f49f1
+	    strncpy(comments,buf,999);
Kevin Fenzi 0f49f1
 	    found_copyright = true;
Kevin Fenzi 0f49f1
 	} else if ( strcmp(tok,"COMMENT")==0 && !found_copyright ) {
Kevin Fenzi 0f49f1
 	    char *pt = comments+strlen(comments);