Modify

Ticket #2783 (closed Bugs: fixed)

Opened 5 years ago

Last modified 4 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:

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

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

Change History

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

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

comment:1 Changed 5 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

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

  • Status changed from closed to reopened
  • Resolution invalid deleted

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

comment:4 Changed 4 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.

View

Add a comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.