[gs-cvs] gs/src

Dan Coby dan at ghostscript.com
Wed Jul 13 14:21:49 PDT 2005

Update of /cvs/ghostscript/gs/src
In directory casper2:/tmp/cvs-serv14049/src

Modified Files:
Log Message:
Fix for 688206 rangecheck in --setcolorspace--.  Actually there is a
problem with the PDF test files.  The 'fix' is to make Ghostscript more
tolerant of errors.


The problem is an error in the file.  The file contains an Indexed color space:
 [ /Indexed /DeviceGray 255 (\000%Mr\r2[\300\320\303\000\b\f\021\026\034"\)UMB9
\267\306\325\005\024"1 at O$3AP_mCQ`o~\214bp\177\216\234\253\200\217\236\255\273
\217\236\255\273\221\237\256\275\314\332\257\276\310\334\352\371$8G4...) ]

The lookup table for this color space should contain 256 bytes.  Instead it 
contains 768 bytes (3 times the needed number of bytes).

The PDF 1.6 specification on page 233 (section 4.55) says:

  The color table data must be m x (hival + 1) bytes long, where m is the
  number of color components in the base color space.

Thus having 768 bytes is an actual error for this case.

Apparently Acrobat 6.0 ignores this error since it does not complain about the 

Since Acrobat accepts these files, I have modified the length test to
accept any look up table which has the needed number of data bytes.

The files were produced by Amyuni PDF Converter (Version 2.08b Pro).

Index: zcsindex.c
RCS file: /cvs/ghostscript/gs/src/zcsindex.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- zcsindex.c	4 Aug 2004 19:36:13 -0000	1.7
+++ zcsindex.c	13 Jul 2005 21:21:47 -0000	1.8
@@ -79,7 +79,13 @@
 	int num_values = num_entries * cs_num_components(&cs);
-	if (r_size(&pcsa[2]) != num_values)
+	/*
+	 * The PDF and PS specifications state that the lookup table must have
+	 * the exact number of of data bytes needed.  However we have found
+	 * PDF files from Amyuni with extra data bytes.  Acrobat 6.0 accepts
+	 * these files without complaint, so we ignore the extra data.
+	 */
+	if (r_size(&pcsa[2]) < num_values)
 	memmove(&cs.params.indexed.base_space, &cs,

More information about the gs-cvs mailing list