CVS commit: xsrc/external/mit/libXfont/dist/src/bitmap

2015-03-17 Thread matthew green
Module Name:xsrc
Committed By:   mrg
Date:   Tue Mar 17 18:11:17 UTC 2015

Modified Files:
xsrc/external/mit/libXfont/dist/src/bitmap: bdfread.c

Log Message:
merge Xfont 1.5.1.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c
diff -u xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c:1.3 xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c:1.4
--- xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c:1.3	Tue Jan  7 07:42:25 2014
+++ xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c	Tue Mar 17 18:11:17 2015
@@ -62,8 +62,16 @@ from The Open Group.
 
 #if HAVE_STDINT_H
 #include stdint.h
-#elif !defined(INT32_MAX)
-#define INT32_MAX 0x7fff
+#else
+# ifndef INT32_MAX
+#  define INT32_MAX 0x7fff
+# endif
+# ifndef INT16_MAX
+#  define INT16_MAX 0x7fff
+# endif
+# ifndef INT16_MIN
+#  define INT16_MIN (0 - 0x8000)
+# endif
 #endif
 
 #define INDICES 256
@@ -417,6 +425,12 @@ bdfReadCharacters(FontFilePtr file, Font
 	bdfError(DWIDTH y value must be zero\n);
 	goto BAILOUT;
 	}
+	/* xCharInfo metrics are stored as INT16 */
+	if ((wx  0) || (wx  INT16_MAX)) {
+	bdfError(character '%s' has out of range width, %d\n,
+		 charName, wx);
+	goto BAILOUT;
+	}
 	line = bdfGetLine(file, lineBuf, BDFLINELEN);
 	if ((!line) || (sscanf((char *) line, BBX %d %d %d %d, bw, bh, bl, bb) != 4)) {
 	bdfError(bad 'BBX'\n);
@@ -427,6 +441,14 @@ bdfReadCharacters(FontFilePtr file, Font
 		 charName, bw, bh);
 	goto BAILOUT;
 	}
+	/* xCharInfo metrics are read as int, but stored as INT16 */
+	if ((bl  INT16_MAX) || (bl  INT16_MIN) ||
+	(bb  INT16_MAX) || (bb  INT16_MIN) ||
+	(bw  (INT16_MAX - bl)) || (bh  (INT16_MAX - bb))) {
+	bdfError(character '%s' has out of range metrics, %d %d %d %d\n,
+		 charName, bl, (bl+bw), (bh+bb), -bb);
+	goto BAILOUT;
+	}
 	line = bdfGetLine(file, lineBuf, BDFLINELEN);
 	if ((line)  (bdfIsPrefix(line, ATTRIBUTES))) {
 	for (p = line + strlen(ATTRIBUTES );
@@ -458,7 +480,10 @@ bdfReadCharacters(FontFilePtr file, Font
 	ci-metrics.descent = -bb;
 	ci-metrics.characterWidth = wx;
 	ci-bits = NULL;
-	bdfReadBitmap(ci, file, bit, byte, glyph, scan, bitmapsSizes);
+	if (!bdfReadBitmap(ci, file, bit, byte, glyph, scan, bitmapsSizes)) {
+		bdfError(could not read bitmap for character '%s'\n, charName);
+		goto BAILOUT;
+	}
 	ci++;
 	ndx++;
 	} else
@@ -604,7 +629,9 @@ bdfReadProperties(FontFilePtr file, Font
 	bdfError(missing 'STARTPROPERTIES'\n);
 	return (FALSE);
 }
-if (sscanf((char *) line, STARTPROPERTIES %d, nProps) != 1) {
+if ((sscanf((char *) line, STARTPROPERTIES %d, nProps) != 1) ||
+	(nProps = 0) ||
+	(nProps  ((INT32_MAX / sizeof(FontPropRec)) - BDF_GENPROPS))) {
 	bdfError(bad 'STARTPROPERTIES'\n);
 	return (FALSE);
 }



CVS commit: xsrc/external/mit/libXfont/dist/src/bitmap

2014-01-06 Thread Thomas Klausner
Module Name:xsrc
Committed By:   wiz
Date:   Tue Jan  7 07:41:59 UTC 2014

Modified Files:
xsrc/external/mit/libXfont/dist/src/bitmap: bdfread.c

Log Message:
CVS-2013-6462:
From aeabb3efa6905e11c479e2e5319f2b6b3ab22009 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith alan.coopersm...@oracle.com
Date: Mon, 23 Dec 2013 18:34:02 -0800
Subject: [PATCH:libXfont 1/2] CVE-2013-: unlimited sscanf can overflow
 stack buffer in bdfReadCharacters()

Fixes cppcheck warning:
 [lib/libXfont/src/bitmap/bdfread.c:341]: (warning)
  scanf without field width limits can crash with huge input data.

Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com
Reviewed-by: Matthieu Herrb matth...@herrb.eu
Reviewed-by: Jeremy Huddleston Sequoia jerem...@apple.com
---
 src/bitmap/bdfread.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r1.2 \
xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c
diff -u xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c:1.1.1.3 xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c:1.2
--- xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c:1.1.1.3	Fri May 31 01:08:57 2013
+++ xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c	Tue Jan  7 07:41:59 2014
@@ -338,7 +338,7 @@ bdfReadCharacters(FontFilePtr file, Font
 	charcharName[100];
 	int ignore;
 
-	if (sscanf((char *) line, STARTCHAR %s, charName) != 1) {
+	if (sscanf((char *) line, STARTCHAR %99s, charName) != 1) {
 	bdfError(bad character name in BDF file\n);
 	goto BAILOUT;	/* bottom of function, free and return error */
 	}



CVS commit: xsrc/external/mit/libXfont/dist/src/bitmap

2014-01-06 Thread Thomas Klausner
Module Name:xsrc
Committed By:   wiz
Date:   Tue Jan  7 07:42:25 UTC 2014

Modified Files:
xsrc/external/mit/libXfont/dist/src/bitmap: bdfread.c

Log Message:
Additional hardening from upstream:

From f8b21df399fbedd08da88752181b8a290a38d890 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith alan.coopersm...@oracle.com
Date: Mon, 23 Dec 2013 19:01:11 -0800
Subject: [PATCH:libXfont 2/2] Limit additional sscanf strings to fit buffer
 sizes

None of these could currently result in buffer overflow, as the input
and output buffers were the same size, but adding limits helps ensure
we keep it that way, if we ever resize any of these in the future.

Fixes cppcheck warnings:
 [lib/libXfont/src/bitmap/bdfread.c:547]: (warning)
  scanf without field width limits can crash with huge input data.
 [lib/libXfont/src/bitmap/bdfread.c:553]: (warning)
  scanf without field width limits can crash with huge input data.
 [lib/libXfont/src/bitmap/bdfread.c:636]: (warning)
  scanf without field width limits can crash with huge input data.

Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com
Reviewed-by: Matthieu Herrb matth...@herrb.eu
Reviewed-by: Jeremy Huddleston Sequoia jerem...@apple.com
---
 src/bitmap/bdfread.c |   14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c
diff -u xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c:1.2 xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c:1.3
--- xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c:1.2	Tue Jan  7 07:41:59 2014
+++ xsrc/external/mit/libXfont/dist/src/bitmap/bdfread.c	Tue Jan  7 07:42:25 2014
@@ -69,6 +69,7 @@ from The Open Group.
 #define INDICES 256
 #define MAXENCODING 0x
 #define BDFLINELEN  1024
+#define BDFLINESTR  %1023s /* scanf specifier to read a BDFLINELEN string */
 
 static Bool bdfPadToTerminal(FontPtr pFont);
 extern int  bdfFileLineNum;
@@ -544,13 +545,18 @@ bdfReadHeader(FontFilePtr file, bdfFileS
 unsigned charlineBuf[BDFLINELEN];
 
 line = bdfGetLine(file, lineBuf, BDFLINELEN);
-if (!line || sscanf((char *) line, STARTFONT %s, namebuf) != 1 ||
+if (!line ||
+sscanf((char *) line, STARTFONT  BDFLINESTR, namebuf) != 1 ||
 	!bdfStrEqual(namebuf, 2.1)) {
 	bdfError(bad 'STARTFONT'\n);
 	return (FALSE);
 }
 line = bdfGetLine(file, lineBuf, BDFLINELEN);
-if (!line || sscanf((char *) line, FONT %[^\n], pState-fontName) != 1) {
+#if MAXFONTNAMELEN != 1024
+# error need to adjust sscanf length limit to be MAXFONTNAMELEN - 1
+#endif
+if (!line ||
+sscanf((char *) line, FONT %1023[^\n], pState-fontName) != 1) {
 	bdfError(bad 'FONT'\n);
 	return (FALSE);
 }
@@ -633,7 +639,9 @@ bdfReadProperties(FontFilePtr file, Font
 	while (*line  isspace(*line))
 	line++;
 
-	switch (sscanf((char *) line, %s%s%s, namebuf, secondbuf, thirdbuf)) {
+	switch (sscanf((char *) line,
+   BDFLINESTR BDFLINESTR BDFLINESTR,
+   namebuf, secondbuf, thirdbuf)) {
 	default:
 	bdfError(missing '%s' parameter value\n, namebuf);
 	goto BAILOUT;



CVS commit: xsrc/external/mit/libXfont/dist/src/bitmap

2012-05-18 Thread Aleksey Cheusov
Module Name:xsrc
Committed By:   cheusov
Date:   Sat May 19 05:16:27 UTC 2012

Modified Files:
xsrc/external/mit/libXfont/dist/src/bitmap: pcfread.c

Log Message:
fix in libxfont:
   An uninitialized pointer causes a crash if pcf header is corrupted
   (upstream patch).


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
xsrc/external/mit/libXfont/dist/src/bitmap/pcfread.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/libXfont/dist/src/bitmap/pcfread.c
diff -u xsrc/external/mit/libXfont/dist/src/bitmap/pcfread.c:1.1.1.2 xsrc/external/mit/libXfont/dist/src/bitmap/pcfread.c:1.2
--- xsrc/external/mit/libXfont/dist/src/bitmap/pcfread.c:1.1.1.2	Wed Jun 10 07:33:40 2009
+++ xsrc/external/mit/libXfont/dist/src/bitmap/pcfread.c	Sat May 19 05:16:27 2012
@@ -408,6 +408,8 @@ pcfReadFont(FontPtr pFont, FontFilePtr f
 
 pFont-info.nprops = 0;
 pFont-info.props = 0;
+pFont-info.isStringProp=0;
+
 if (!(tables = pcfReadTOC(file, ntables)))
 	goto Bail;