Subject: pkg/24759: imlib doesn't parse some pnm file correctly.
To: None <>
From: None <>
List: netbsd-bugs
Date: 03/13/2004 08:08:35
>Number:         24759
>Category:       pkg
>Synopsis:       imlib doesn't parse some pnm file correctly.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 12 23:09:00 UTC 2004
>Originator:     enami tsugutomo
>Release:        NetBSD 1.6ZK
System: NetBSD 1.6ZK NetBSD 1.6ZK (CUTIE_HONEY.UP.PROF) #326: Sat Mar 13 07:27:25 JST 2004 i386
Architecture: i386
Machine: i386
imlib-1.9.14nb5     Image manipulation library for X11
	imlib uses sscanf() with %i to parse height, width and maxval of
	ppm file, but manual page (linked from man pnm, ppm etc) clearly
	says that those value are decimal.  So, it should use %d
	instead of %i.  Some application actually writes some of
	those value with 0 prepended (e.g., xsane uses printf() with %05d).
	With xsane, scan and save it in pnm format.  Load the file with
	imlib (e.g., qiv).

	Or, read the source code of those software.

Here is a fix (but maxval change isn't tested).

--- gdk_imlib/io-ppm.c	2004/03/07 05:30:32	1.1
+++ gdk_imlib/io-ppm.c	2004/03/07 05:33:21
@@ -50,7 +50,7 @@
       if (s[0] != '#')
 	  done = 0;
-	  sscanf(s, "%i %i", w, h);
+	  sscanf(s, "%d %d", w, h);
 	  a = *w;
 	  b = *h;
 	  if (a > 32767)
@@ -66,7 +66,7 @@
 	  if (!bw)
 	      fgets(s, 256, f);
-	      sscanf(s, "%i", &scale);
+	      sscanf(s, "%d", &scale);
 	    scale = 99999;