[gs-cvs] rev 7086 - trunk/gs/src

alexcher at ghostscript.com alexcher at ghostscript.com
Wed Oct 4 18:45:56 PDT 2006


Author: alexcher
Date: 2006-10-04 18:45:56 -0700 (Wed, 04 Oct 2006)
New Revision: 7086

Modified:
   trunk/gs/src/gdevpdfr.c
Log:
Pacify Valgrind. Copy a non 0-terminated PS string to a local buffer to avoid
scanning past the end of the string. Bug 688882.

DIFFERENCES:
None


Modified: trunk/gs/src/gdevpdfr.c
===================================================================
--- trunk/gs/src/gdevpdfr.c	2006-10-05 01:09:35 UTC (rev 7085)
+++ trunk/gs/src/gdevpdfr.c	2006-10-05 01:45:56 UTC (rev 7086)
@@ -121,10 +121,12 @@
      * Check for a predefined name.  Map ThisPage, PrevPage, and NextPage
      * to the appropriate Page<#> name.
      */
-    if (pname->size >= 7 &&
-	sscanf((const char *)pname->data, "{Page%d}", &page_number) == 1
-	)
-	goto cpage;
+    if (pname->size >= 7 && pname->size < sizeof(page_name_chars)) {
+        memcpy(page_name_chars, pname->data, pname->size);
+        page_name_chars[pname->size] = 0;
+	if (sscanf(page_name_chars, "{Page%d}", &page_number) == 1)
+	    goto cpage;
+    }
     if (pdf_key_eq(pname, "{ThisPage}"))
 	page_number = pdev->next_page + 1;
     else if (pdf_key_eq(pname, "{NextPage}"))



More information about the gs-cvs mailing list