[gs-commits] rev 11649 - trunk/gs/base

ken at ghostscript.com ken at ghostscript.com
Mon Aug 23 16:49:47 UTC 2010


Author: ken
Date: 2010-08-23 16:49:47 +0000 (Mon, 23 Aug 2010)
New Revision: 11649

Modified:
   trunk/gs/base/gdevpdfe.c
Log:
Fix (pdfwrite) : errors in XMP metadata parsing

Bug #691562 "ERROR -15 closing pdfwrite device".

This use of a DOCINFO pdfmark exposed 3 separate bugs in pdfwrite's handling of XMP
metadata.

1) Decoding an escaped PostScript string. Unescaped characters and octal escapes worked
correctly, but non-octal escapes moved the index into the string one place too many.

2) The escape '\b' (backspace) wasn't handled and returned incorrect data. Although not
tested by this issue, the form feed (\f) also wasn't handled.

3) When converting UTF16 data to UTF-8, the end of the destination (UTF-8) buffer was
calculated incorrectly, causing a spurious buffer overrun error.

The code now handles the missing escapes, does not advance the character position after
decoding a non-octal escape and correctly defines the end of buffer. After this the
Title string displays the same in Acrobat as the same pdfmark sent through Adobe
Distiller.

No expected differences as this only affects the document metadata.


Modified: trunk/gs/base/gdevpdfe.c
===================================================================
--- trunk/gs/base/gdevpdfe.c	2010-08-21 08:03:46 UTC (rev 11648)
+++ trunk/gs/base/gdevpdfe.c	2010-08-23 16:49:47 UTC (rev 11649)
@@ -292,12 +292,14 @@
 	return 0; /* Must_not_happen, because the string is PS encoded. */
     c = data[*index];
     switch (c) {
-	case '(': (*index)++; return '(';
-	case ')': (*index)++; return ')';
-	case '\\': (*index)++; return '\\';
-	case 'n': (*index)++; return '\n';
-	case 'r': (*index)++; return '\r';
-	case 't': (*index)++; return '\t';
+	case '(': return '(';
+	case ')': return ')';
+	case '\\': return '\\';
+	case 'n': return '\n';
+	case 'r': return '\r';
+	case 't': return '\t';
+	case 'b': return '\b';
+	case 'f': return '\f';
 	default:
 	    break;
     }
@@ -368,7 +370,7 @@
 	    }
 	    buf0b = (UTF16 *)(buf0 + 2);
 	    switch (ConvertUTF16toUTF8((const UTF16**)&buf0b, (UTF16 *)(buf0 + j),
-			     &buf1b, buf1 + j, strictConversion)) {
+			     &buf1b, buf1 + (data_length * sizeof(unsigned char)), strictConversion)) {
 		case conversionOK:
 		    write(s, buf1, buf1b - buf1);
 		    gs_free_object(pdev->memory, buf1, "pdf_xmp_write_translated");



More information about the gs-commits mailing list