Package: netpbm
Version: 2:10.0-8
Severity: normal
Tags: patch

Hi,

If given an eps file with %%BoundingBox -1 <lly> <urx> <ury>, psopnm
will happily ignore it (without providing a diagnostic to the user, even
in verbose mode) and use whatever defaults it has chosen.  However, I
believe real world .eps files can have -1 as the lower left coordinate
of the bounding box, and certainly the ones I generated today did, so
the logic in pstopnm.c is inadequate for detecting whether a BoundingBox
has been found or not.  (The same applies to bounds specified on the
command line)

A lightly-tested patch will follow this report.

Cheers,

Christophe

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.10-1-386
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)

Versions of packages netpbm depends on:
ii  bc                            1.06-17    The GNU bc arbitrary precision cal
ii  libc6                         2.3.5-4    GNU C Library: Shared libraries an
ii  libjpeg62                     6b-10      The Independent JPEG Group's JPEG 
ii  libnetpbm10                   2:10.0-8   Shared libraries for netpbm
ii  libpng12-0                    1.2.8rel-1 PNG library - runtime
ii  libtiff4                      3.7.2-3    Tag Image File Format (TIFF) libra
ii  zlib1g                        1:1.2.3-3  compression library - runtime

Versions of packages netpbm recommends:
ii  gs                            8.15-3     Transitional package
ii  gs-gpl [gs]                   8.15-3     The GPL Ghostscript PostScript int

-- no debconf information
--- netpbm-free-10.0/pnm/pstopnm.c	2004-01-05 10:39:56.000000000 +0000
+++ netpbm-free-10.0.new/pnm/pstopnm.c	2005-08-27 20:45:03.000000000 +0100
@@ -39,6 +39,7 @@
     char *input_filespec;  /* Filespecs of input files */
     unsigned int forceplain;
     struct box extract_box;
+    int extract_box_supplied;
     unsigned int nocrop;
     unsigned int format_type;
     unsigned int verbose;
@@ -145,8 +146,9 @@
         else cmdline_p->extract_box.urx = urx * 72;
         if (!urySpec) cmdline_p->extract_box.ury = 720;
         else cmdline_p->extract_box.ury = ury * 72;
+        cmdline_p->extract_box_supplied = TRUE;
     } else {
-        cmdline_p->extract_box.llx = -1;
+        cmdline_p->extract_box_supplied = FALSE;
     }
 
 }
@@ -284,26 +286,28 @@
 
     struct box retval;
 
-    if (cmdline.extract_box.llx != -1)
+    if (cmdline.extract_box_supplied == TRUE)
         /* User told us what box to extract, so that's what we'll do */
         retval = cmdline_extract_box;
     else {
         /* Try to get the bounding box from the DSC %%BoundingBox
            statement (A Postscript comment) in the input.
         */
-        struct box ps_bb;  /* Box described by %%BoundingBox stmt in input */
+        struct box ps_bb;  /* Box described by %%BoundingBox stmt in
+                              input */
+        int found_BB; /* logical */
 
+        found_BB = FALSE;
         if (strcmp(input_filespec, "-") == 0)
             /* Can't read stdin, because we need it positioned for the 
                Ghostscript interpreter to read it.
             */
-            ps_bb.llx = -1;
+            ;
         else {
             FILE *infile;
-            int found_BB, eof;  /* logical */
+            int eof;  /* logical */
             infile = pm_openr(input_filespec);
             
-            found_BB = FALSE;
             eof = FALSE;
             while (!eof && !found_BB) {
                 char line[200];
@@ -322,13 +326,12 @@
             fclose(infile);
 
             if (!found_BB) {
-                ps_bb.llx = -1;
                 pm_message("Warning: no %%%%BoundingBox statement "
                            "in the input or command line.\n"
                            "Will use defaults");
             }
         }
-        if (ps_bb.llx != -1) {
+        if (found_BB) {
             if (verbose)
                 pm_message("Using %%%%BoundingBox statement from input.");
             retval = ps_bb;

Reply via email to