Sophie

Sophie

distrib > Mageia > 5 > x86_64 > by-pkgid > 63b2c18782c11b518318b02cb0efbc8e > files > 4

libxfont-1.5.1-1.2.mga5.src.rpm

--- libxfont-1.5.1.orig/src/bitmap/pcfread.c
+++ libxfont-1.5.1/src/bitmap/pcfread.c
@@ -44,6 +44,7 @@
 
 #include <stdarg.h>
 #include <stdint.h>
+#include <string.h>
 
 void
 pcfError(const char* message, ...)
@@ -310,11 +311,19 @@
     if (IS_EOF(file)) goto Bail;
     position += string_size;
     for (i = 0; i < nprops; i++) {
+	if (props[i].name >= string_size) {
+	    pcfError("pcfGetProperties(): String starts out of bounds (%ld/%d)\n", props[i].name, string_size);
+	    goto Bail;
+	}
 	props[i].name = MakeAtom(strings + props[i].name,
-				 strlen(strings + props[i].name), TRUE);
+				 strnlen(strings + props[i].name, string_size - props[i].name), TRUE);
 	if (isStringProp[i]) {
+	    if (props[i].value >= string_size) {
+		pcfError("pcfGetProperties(): String starts out of bounds (%ld/%d)\n", props[i].value, string_size);
+		goto Bail;
+	    }
 	    props[i].value = MakeAtom(strings + props[i].value,
-				      strlen(strings + props[i].value), TRUE);
+				      strnlen(strings + props[i].value, string_size - props[i].value), TRUE);
 	}
     }
     free(strings);