Blame SOURCES/graphviz-2.30.1-CVE-2014-1236.patch

bfa7ee
From 1d1bdec6318746f6f19f245db589eddc887ae8ff Mon Sep 17 00:00:00 2001
bfa7ee
From: "Emden R. Gansner" <erg@alum.mit.edu>
bfa7ee
Date: Wed, 8 Jan 2014 11:31:04 -0500
bfa7ee
Subject: [PATCH] Fix possible buffer overflow problem in chkNum of scanner.
bfa7ee
bfa7ee
---
bfa7ee
 lib/cgraph/scan.l | 35 ++++++++++++++++++++++++++---------
bfa7ee
 1 file changed, 26 insertions(+), 9 deletions(-)
bfa7ee
bfa7ee
diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l
bfa7ee
index 212967c..d065b61 100644
bfa7ee
--- a/lib/cgraph/scan.l
bfa7ee
+++ b/lib/cgraph/scan.l
bfa7ee
@@ -129,15 +129,32 @@ static void ppDirective (void)
bfa7ee
  * and report this to the user.
bfa7ee
  */
bfa7ee
 static int chkNum(void) {
bfa7ee
-  unsigned char	c = (unsigned char)yytext[yyleng-1];   /* last character */
bfa7ee
-  if (!isdigit(c) && (c != '.')) {  /* c is letter */
bfa7ee
-	char	buf[BUFSIZ];
bfa7ee
-	sprintf(buf,"syntax error - badly formed number '%s' in line %d of %s\n",yytext,line_num, InputFile);
bfa7ee
-    strcat (buf, "splits into two name tokens\n");
bfa7ee
-	agerr(AGWARN,buf);
bfa7ee
-    return 1;
bfa7ee
-  }
bfa7ee
-  else return 0;
bfa7ee
+    unsigned char c = (unsigned char)yytext[yyleng-1];   /* last character */
bfa7ee
+    if (!isdigit(c) && (c != '.')) {  /* c is letter */
bfa7ee
+	unsigned char xbuf[BUFSIZ];
bfa7ee
+	char buf[BUFSIZ];
bfa7ee
+	agxbuf  xb;
bfa7ee
+	char* fname;
bfa7ee
+
bfa7ee
+	if (InputFile)
bfa7ee
+	    fname = InputFile;
bfa7ee
+	else
bfa7ee
+	    fname = "input";
bfa7ee
+
bfa7ee
+	agxbinit(&xb, BUFSIZ, xbuf);
bfa7ee
+
bfa7ee
+	agxbput(&xb,"syntax ambiguity - badly delimited number '");
bfa7ee
+	agxbput(&xb,yytext);
bfa7ee
+	sprintf(buf,"' in line %d of ", line_num);
bfa7ee
+	agxbput(&xb,buf);
bfa7ee
+	agxbput(&xb,fname);
bfa7ee
+	agxbput(&xb, " splits into two tokens\n");
bfa7ee
+	agerr(AGWARN,agxbuse(&xb));
bfa7ee
+
bfa7ee
+	agxbfree(&xb;;
bfa7ee
+	return 1;
bfa7ee
+    }
bfa7ee
+    else return 0;
bfa7ee
 }
bfa7ee
 
bfa7ee
 /* The LETTER class below consists of ascii letters, underscore, all non-ascii
bfa7ee
-- 
bfa7ee
1.8.5.1
bfa7ee