Ticket #2783 (closed Bugs: fixed)

Opened 7 years ago

Last modified 5 years ago

bzip2_decompressor infinite loops with truncated input file

Reported by: Mark Westcott <markboost@…> Owned by: turkanis
Milestone: Component: iostreams
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:


Hi. This is a re-report of a problem posted to boost-users in 2005,

I have attached the sample program from that post.

To reproduce:

echo -e "Hello world\n" | bzip2 > hello-complete.bz2 
dd if=hello-complete.bz2 of=hello.bz2 bs=1 count=53 

The program never terminates.

This behaviour is exhibited with both gcc 4.3 and VC8 using latest boost release.


Attachments Download (467 bytes) - added by Mark Westcott <markboost@…> 7 years ago.
hello.bz2 Download (53 bytes) - added by Mark Westcott <markboost@…> 7 years ago.

Change History

Changed 7 years ago by Mark Westcott <markboost@…>

Changed 7 years ago by Mark Westcott <markboost@…>

comment:1 Changed 6 years ago by agander@…

  • Status changed from new to closed
  • Resolution set to invalid

Is this a valid test/error?

bzip2 reports that hello.bz2 is corrupt.

bzip2 -tvvv hello.bz2


[1: huff+mtf rt+rld {0x13cbede3, 0x13cbede3}]file ends unexpectedly

You can use the `bzip2recover' program to attempt to recover data from undamaged sections of corrupted files.

It works fine once recovered.

But then this isnt a Boost issue.

Tested on:


gcc -v:- Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl= --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj- --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-cpu=generic --build=x86_64-redhat-linux Thread model: posix gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC)

Linux #1 SMP x86_64 GNU/Linux

comment:2 Changed 6 years ago by markboost@…

I disagree. (As does Jonathan Turkanis -

The correct behaviour is to throw an exception (probably boost::iostreams::data_error) (like the gzip filter does) - infinite looping with invalid input really isn't good. Just like bzip2 reports the file is corrupt, so should this filter.

comment:3 Changed 6 years ago by agander@…

  • Status changed from closed to reopened
  • Resolution invalid deleted

Ok, fair point. (Thats an embarassing start...)

comment:4 Changed 5 years ago by steven_watanabe

  • Status changed from reopened to closed
  • Resolution set to fixed

(In [62965]) Throw an exception on an unexpected end of file in bzip2_decompressor instead of going into an infinite loop. Fixes #2783.


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.