Subject: xfig: wrong search of mediabox when importing PDF
Package: xfig
Version: 1:3.2.5-rel-3
Severity: normal
Tags: patch

*** Please type your report below this line ***

When you import a PDF file, xfig tries to calculate the size of object by 
searching "/MediaBox" attribute. But it only tries to find the attribute at the 
begining of a 
line.

Moreover, in the same stanza, it calls "strchr" and adds +1 then compares the 
result to NULL for error checking. But the +1 makes the errochecking incrorrect.

The included patch corrects this.

-- System Information:
Debian Release: 5.0.1
  APT prefers stable
  APT policy: (900, 'stable'), (50, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.27.9 (PREEMPT)
Locale: lang=fr...@euro, lc_ctype=fr...@euro (charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/bash

Versions of packages xfig depends on:
ii  libc6                    2.7-18          GNU C Library: Shared libraries
ii  libjpeg62                6b-14           The Independent JPEG Group's JPEG 
ii  libpng12-0               1.2.27-2+lenny2 PNG library - runtime
ii  libx11-6                 2:1.1.5-2       X11 client-side library
ii  libxi6                   2:1.1.4-1       X11 Input extension library
ii  libxpm4                  1:3.5.7-1       X11 pixmap library
ii  libxt6                   1:1.0.5-3       X11 toolkit intrinsics library
ii  xaw3dg                   1.5+E-17        Xaw3d widget set

Versions of packages xfig recommends:
ii  transfig                 1:3.2.5-rel-3.1 Utilities for converting XFig figu
ii  xfig-libs                1:3.2.5-rel-3   XFig image libraries and examples

Versions of packages xfig suggests:
ii  cups-bsd [lpr]     1.3.8-1lenny5         Common UNIX Printing System(tm) - 
ii  cups-client        1.3.8-1lenny5         Common UNIX Printing System(tm) - 
ii  ghostscript        8.62.dfsg.1-3.2lenny1 The GPL Ghostscript PostScript/PDF
ii  gimp               2.4.7-1               The GNU Image Manipulation Program
ii  gsfonts-x11        0.21                  Make Ghostscript fonts available t
ii  netpbm             2:10.0-12             Graphics conversion tools
pn  spell              <none>                (no description available)
pn  xfig-doc           <none>                (no description available)

-- no debconf information
--- /opt/tmp/xfig-3.2.5-rel/f_readeps.c	2005-10-31 18:40:38.000000000 +0100
+++ xfig-3.2.5-rel/f_readeps.c	2009-05-27 21:19:54.000000000 +0200
@@ -77,11 +77,13 @@
 
 	/* look for /MediaBox for pdf file */
 	if (pdf_flag) {
-	    if (!strncmp(buf, "/MediaBox", 8)) {	/* look for the MediaBox spec */
+	  char *s;
+	  for(s=buf; (s=strchr(s,'/')); s++) {
+	    if (!strncmp(s, "/MediaBox", 8)) {	/* look for the MediaBox spec */
 		char       *c;
 
-		c = strchr(buf, '[') + 1;
-		if (c && sscanf(c, "%d %d %d %d", &llx, &lly, &urx, &ury) < 4) {
+		c = strchr(s, '[');
+		if (c && sscanf(c+1, "%d %d %d %d", &llx, &lly, &urx, &ury) < 4) {
 		    llx = lly = 0;
 		    urx = paper_sizes[0].width * 72 / PIX_PER_INCH;
 		    ury = paper_sizes[0].height * 72 / PIX_PER_INCH;
@@ -89,7 +91,9 @@
 			     appres.INCHES ? "Letter" : "A4");
 		    app_flush();
 		}
+		break;
 	    }
+	  }
 	    /* look for bounding box */
 	} else if (!nested && !strncmp(buf, "%%BoundingBox:", 14)) {
 	    if (!strstr(buf, "(atend)")) {	/* make sure doesn't say (atend) */

Reply via email to