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 xxxxx' > 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 (b&w), 1x5
    BG44 [3]          IW4 data #2, 15 slices
    BG44 [2]          IW4 data #3, 10 slices


$ printf 'P5 1 4 255 xxxx' > 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  libdjvulibre15                3.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++6 4.2.2-4 The GNU Standard C++ Library v3
ii  libtiff4                      3.8.2-7    Tag 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.000000000 +0100
+++ djvulibre-3.5.19/tools/c44.cpp	2007-12-09 19:06:35.000000000 +0100
@@ -704,7 +704,8 @@
       GP<ByteStream> 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

Reply via email to