Package: bzip2 Version: 1.0.2-3 Severity: normal
The example code included in the documentation will silently drop the last block of data. The file /usr/share/doc/bzip2/manual_3.html contains the following example: FILE* f; BZFILE* b; int nBuf; char buf[ /* whatever size you like */ ]; int bzerror; int nWritten; f = fopen ( "myfile.bz2", "r" ); if (!f) { /* handle error */ } b = BZ2_bzReadOpen ( &bzerror, f, 0, NULL, 0 ); if (bzerror != BZ_OK) { BZ2_bzReadClose ( &bzerror, b ); /* handle error */ } bzerror = BZ_OK; while (bzerror == BZ_OK && /* arbitrary other conditions */) { nBuf = BZ2_bzRead ( &bzerror, b, buf, /* size of buf */ ); ==> if (bzerror == BZ_OK) { /* do something with buf[0 .. nBuf-1] */ } } if (bzerror != BZ_STREAM_END) { BZ2_bzReadClose ( &bzerror, b ); /* handle error */ } else { BZ2_bzReadClose ( &bzerror ); } The line marked with "==>" should be changed to: if (nBuf) { I've checked the libbz's source -- every error will return 0, and non-zero nBuf guarantees that bzerror is either BZ_OK or BZ_STREAM_END. The problem is, if the latter is returned, we still need to process the last block. While we're at it, could you also s/"r"/"rb"/ in the fopen line, to help some poor sap who'll port some software using bzlib to a grossly inferior platform? Regards, 1KB -- System Information: Debian Release: 3.1 APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.9 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Versions of packages bzip2 depends on: ii libbz2-1.0 1.0.2-1 A high-quality block-sorting file ii libc6 2.3.2.ds1-20 GNU C Library: Shared libraries an -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]