Package: lbzip2
Version: 0.23-1
Severity: normal

lbunzip2 makes a bad assumption about maximal bzip2 block size
and as a result it fails to decompress some valid bzip2
files (which are properly handled by bzip2 program).

Attached C program produces (writes to stdout) valid bz2 files
that can't be decompressed using lbzip2.


/*** p1.c ****************************************************************/

#if FILE_SIZE < 171
#undef FILE_SIZE
#define FILE_SIZE 171
#endif

p(x,n) {
  static long b,k;
  b = (b << n) + x, k += n;
  while (k >= 8)
    putchar((b >> (k -= 8)) & 0xff);
}
pb(b) { p(b,8); }

main() {
  long i,j;
  long crc=0x81b02d8b;
  pb('B'); pb('Z'); pb('h'); pb('9');     /* magic */
  p(0x314159,24); p(0x265359, 24);        /* block header */
  p((crc>>16)&0xffff,16); p(crc&0xffff,16);
  p(0,1);   /* block randomised? */
  p(0,24);  /* bwt index */
  for (i=16+256-2; i--;) p(1,1);  /* bitmap */
  p(0,2);
  p(2,3); p(3,15); p(0,3);
  for (j=2; j--;) {               /* code lens for both groups */
    p(8,5);                       /* all codes are 8-bit */
    for (i=255+j; i--;) p(0,1);   /* delta */
    if(!j) { for (i=FILE_SIZE-171;i--;) p(0xEB,8); p(0,1); }
  }

  pb('A'+1);
  pb(0xff);
  p(0x177245,24); p(0x385090,24);
  p((crc>>16)&0xffff,16); p(crc&0xffff,16);

  pb(0x42); pb(0x5A); pb(0x68); pb(0x39); pb(0x31); pb(0x41); pb(0x59);
  pb(0x26); pb(0x53); pb(0x59); pb(0x21); pb(0x26); pb(0x1F); pb(0x78);
  pb(0x00); pb(0x00); pb(0x00); pb(0xC4); pb(0x00); pb(0x00); pb(0x10);
  pb(0x18); pb(0x00); pb(0x20); pb(0x00); pb(0x21); pb(0x98); pb(0x19);
  pb(0x84); pb(0x61); pb(0x77); pb(0x24); pb(0x53); pb(0x85); pb(0x09);
  pb(0x02); pb(0x12); pb(0x61); pb(0xF7); pb(0x80);
}

/*************************************************************************/


$ cc -DFILE_SIZE=1000000 -ot1 p1.c
$ ./t1 >t1a.bz2
$ bzcat t1a.bz2
ABC
$ lbzip2 -d -n 2 t1a.bz2
lbzip2: "t1a.bz2": compressed block too long
$ cc -DFILE_SIZE=2000000 -ot2 p1.c
$ ./t2 >t2a.bz2
$ bzcat t2a.bz2
ABC
$ lbzip2 -d -n 2 t2a.bz2
lbzip2: "t2a.bz2": missing bzip2 block header in full first input block
$



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

Kernel: Linux 2.6.32-trunk-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages lbzip2 depends on:
ii  libbz2-1.0                    1.0.5-4    high-quality block-sorting file co
ii  libc6                         2.10.2-8   Embedded GNU C Library: Shared lib

lbzip2 recommends no packages.

lbzip2 suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to