Skip Menu |

This queue is for tickets about the Compress-Bzip2 CPAN distribution.

Report information
The Basics
Id: 36246
Status: resolved
Priority: 0/
Queue: Compress-Bzip2

People
Owner: Nobody in particular
Requestors: GWOLF [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.09
Fixed in: (no value)



Subject: Compressing an empty file yields an empty (i.e. invalid) file
Hi, I'm filing this bug as a followup to the corresponding bug report in Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=464205 Andres Mejia, the bug submitter, found out that trying to compress a zero-byte file results in creating a zero-byte .bz2 file - which is clearly invalid. I am attaching here the bzip2test test case he sent to illustrate the point (patched with Jeffrey Ratcliffe's further comment - see bug report). I'll also attach the file that fixes this problem. I am uploading a patched release to Debian, but I'd be most grateful if you include this fix (or any fix, of course ;-) ) to your code.
Subject: bzip2test
Download bzip2test
application/octet-stream 1.3k

Message body not shown because it is not plain text.

On Wed May 28 10:48:20 2008, GWOLF wrote: Show quoted text
> Hi, > I'm filing this bug as a followup to the corresponding bug report in
Debian: Show quoted text
> > http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=464205 > > Andres Mejia, the bug submitter, found out that trying to compress a > zero-byte file results in creating a zero-byte .bz2 file - which is > clearly invalid. I am attaching here the bzip2test test case he sent to > illustrate the point (patched with Jeffrey Ratcliffe's further comment - > see bug report). > > I'll also attach the file that fixes this problem. I am uploading a > patched release to Debian, but I'd be most grateful if you include this > fix (or any fix, of course ;-) ) to your code.
--- libcompress-bzip2-perl-2.09.orig/Bzip2.xs +++ libcompress-bzip2-perl-2.09/Bzip2.xs @@ -1485,8 +1485,6 @@ return -2; } - if (nUncompressed == 0) return 0; - while (True) { if ( obj->run_progress == 0 ) { ret = BZ2_bzCompressInit ( &(obj->strm), obj->blockSize100k, obj->verbosity, obj->workFactor ); @@ -2253,12 +2251,10 @@ else bufp = SvPV(buf, len); - if (len) { - RETVAL = bzfile_write( obj, bufp, len); + RETVAL = bzfile_write( obj, bufp, len); - if ( RETVAL > 0 ) + if ( RETVAL > 0 ) SvCUR_set( buf, RETVAL ); - } } OUTPUT: --- libcompress-bzip2-perl-2.09.orig/debian/changelog +++ libcompress-bzip2-perl-2.09/debian/changelog @@ -0,0 +1,26 @@ +libcompress-bzip2-perl (2.09-1.2) unstable; urgency=low + + * Non-maintainer upload. + * Fix bug compressing empty files (closes: #464205) + + -- Jeffrey Ratcliffe <Jeffrey.Ratcliffe@gmail.com> Wed, 21 May 2008 20:55:33 +0200 + libcompress-bzip2-perl (2.09-1.1) unstable; urgency=low * Non-maintainer upload.
Patch for the bug included here
--- libcompress-bzip2-perl-2.09.orig/Bzip2.xs +++ libcompress-bzip2-perl-2.09/Bzip2.xs @@ -1485,8 +1485,6 @@ return -2; } - if (nUncompressed == 0) return 0; - while (True) { if ( obj->run_progress == 0 ) { ret = BZ2_bzCompressInit ( &(obj->strm), obj->blockSize100k, obj->verbosity, obj->workFactor ); @@ -2253,12 +2251,10 @@ else bufp = SvPV(buf, len); - if (len) { - RETVAL = bzfile_write( obj, bufp, len); + RETVAL = bzfile_write( obj, bufp, len); - if ( RETVAL > 0 ) + if ( RETVAL > 0 ) SvCUR_set( buf, RETVAL ); - } } OUTPUT: --- libcompress-bzip2-perl-2.09.orig/debian/changelog +++ libcompress-bzip2-perl-2.09/debian/changelog @@ -0,0 +1,26 @@ +libcompress-bzip2-perl (2.09-1.2) unstable; urgency=low + + * Non-maintainer upload. + * Fix bug compressing empty files (closes: #464205) + + -- Jeffrey Ratcliffe <Jeffrey.Ratcliffe@gmail.com> Wed, 21 May 2008 20:55:33 +0200 + libcompress-bzip2-perl (2.09-1.1) unstable; urgency=low * Non-maintainer upload.
Thanks. The fix plus a testcase will be in the upcoming 2.10. See https://github.com/rurban/Compress-Bzip2/commit/810e08007a39eebd136c505bddddab99f289fdea -- Reini Urban