Bug#455331: c44: unable to encode very small files

2007-12-09 Thread Jakub Wilk

Package: djvulibre-bin
Version: 3.5.19-3
Severity: normal
Tags: patch

c44 is unable to encode image files if they are smaller than 16 bytes.


$ printf 'P5 1 5 255 x'  pgm16.pgm
$ c44 pgm16.pgm
$ djvudump pgm16.djvu
  FORM:DJVU [66]
INFO [10] DjVu 1x5, v24, 100 dpi, gamma=2.2
BG44 [13] IW4 data #1, 74 slices, v1.2 (bw), 1x5
BG44 [3]  IW4 data #2, 15 slices
BG44 [2]  IW4 data #3, 10 slices


$ printf 'P5 1 4 255 '  pgm15.pgm
$ c44 pgm15.pgm
*** [1-17556] cannot read pnm file header
*** (c44.cpp:708)
*** 'int main(int, char**)'


The attached patch fixes this bug.

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (900, 'testing'), (600, 'unstable'), (500, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-3-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=pl_PL (charmap=ISO-8859-2)
Shell: /bin/sh linked to /bin/dash

Versions of packages djvulibre-bin depends on:
ii  curl  7.17.1-1   Get a file from an HTTP, HTTPS or 
ii  libc6 2.7-3  GNU C Library: Shared libraries

ii  libdjvulibre153.5.19-3   Runtime support for the DjVu image
ii  libgcc1   1:4.2.2-4  GCC support library
ii  libjpeg62 6b-14  The Independent JPEG Group's JPEG 
ii  libstdc++64.2.2-4The GNU Standard C++ Library v3

ii  libtiff4  3.8.2-7Tag Image File Format (TIFF) libra

djvulibre-bin recommends no packages.

-- no debconf information

--
Jakub Wilk
--- djvulibre-3.5.19.orig/tools/c44.cpp	2007-12-09 18:22:27.0 +0100
+++ djvulibre-3.5.19/tools/c44.cpp	2007-12-09 19:06:35.0 +0100
@@ -704,7 +704,8 @@
   GPByteStream gibs=ByteStream::create(g().pnmurl,rb);
   ByteStream ibs=*gibs;
   char prefix[16];
-  if (ibs.readall((void*)prefix, sizeof(prefix)) != sizeof(prefix))
+  memset(prefix, 0, sizeof(prefix));
+  if (ibs.readall((void*)prefix, sizeof(prefix))  10)
 G_THROW( ERR_MSG(c44.failed_pnm_header) );
 #ifdef DEFAULT_JPEG_TO_HALF_SIZE
   // Default specification for jpeg files


Bug#455331: c44: unable to encode very small files

2007-12-09 Thread Barak A. Pearlmutter
Thanks for the bug report  patch.

One minor thing.  I can't send this patch, as written, upstream: a
magic number 10 cannot go in the middle of some code.

The 10 comes from INFO [10], right?  There must be a right way to
refer to the length of the info field.
--
Barak A. Pearlmutter
 Hamilton Institute  Dept Comp Sci, NUI Maynooth, Co. Kildare, Ireland
 http://www.bcl.hamilton.ie/~barak/



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]