Modify

Opened 9 years ago

Closed 7 years ago

#2783 closed Bugs (fixed)

bzip2_decompressor infinite loops with truncated input file

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

Description

Hi. This is a re-report of a problem posted to boost-users in 2005, http://lists.boost.org/boost-users/2005/10/14361.php

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 
./hello

The program never terminates.

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

TIA.

Attachments (2)

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

Download all attachments as: .zip

Change History (6)

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

Attachment: hello.cc added

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

Attachment: hello.bz2 added

comment:1 Changed 8 years ago by agander@…

Resolution: invalid
Status: newclosed

Is this a valid test/error?

bzip2 reports that hello.bz2 is corrupt.

bzip2 -tvvv hello.bz2

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:

BOOST_VERSION: 103800 BOOST_LIB_VERSION: 1_38

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=http://bugzilla.redhat.com/bugzilla --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-1.5.0.0/jre --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 2.6.27.24-170.2.68.fc10.x86_64 #1 SMP x86_64 GNU/Linux

comment:2 Changed 8 years ago by markboost@…

I disagree. (As does Jonathan Turkanis - http://lists.boost.org/boost-users/2005/10/14362.php).

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 8 years ago by agander@…

Resolution: invalid
Status: closedreopened

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

comment:4 Changed 7 years ago by Steven Watanabe

Resolution: fixed
Status: reopenedclosed

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonathan Turkanis.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.