Boost C++ Libraries: Ticket #2783: bzip2_decompressor infinite loops with truncated input file https://svn.boost.org/trac10/ticket/2783 <p> Hi. This is a re-report of a problem posted to boost-users in 2005, <a class="ext-link" href="http://lists.boost.org/boost-users/2005/10/14361.php"><span class="icon">​</span>http://lists.boost.org/boost-users/2005/10/14361.php</a> </p> <p> I have attached the sample program from that post. </p> <p> To reproduce: </p> <pre class="wiki"> echo -e "Hello world\n" | bzip2 &gt; hello-complete.bz2 dd if=hello-complete.bz2 of=hello.bz2 bs=1 count=53 ./hello </pre><p> The program never terminates. </p> <p> This behaviour is exhibited with both gcc 4.3 and VC8 using latest boost release. </p> <p> TIA. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2783 Trac 1.4.3 Mark Westcott <markboost@…> Fri, 20 Feb 2009 09:43:01 GMT attachment set https://svn.boost.org/trac10/ticket/2783 https://svn.boost.org/trac10/ticket/2783 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">hello.cc</span> </li> </ul> Ticket Mark Westcott <markboost@…> Fri, 20 Feb 2009 09:43:11 GMT attachment set https://svn.boost.org/trac10/ticket/2783 https://svn.boost.org/trac10/ticket/2783 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">hello.bz2</span> </li> </ul> Ticket agander@… Fri, 05 Jun 2009 20:01:02 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2783#comment:1 https://svn.boost.org/trac10/ticket/2783#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> Is this a valid test/error? </p> <p> bzip2 reports that hello.bz2 is corrupt. </p> <blockquote class="citation"> <p> bzip2 -tvvv hello.bz2 </p> </blockquote> <blockquote> <p> hello.bz2: </p> <blockquote> <p> [1: huff+mtf rt+rld {0x13cbede3, 0x13cbede3}]file ends unexpectedly </p> </blockquote> </blockquote> <p> You can use the `bzip2recover' program to attempt to recover data from undamaged sections of corrupted files. </p> <p> It works fine once recovered. </p> <p> But then this isnt a Boost issue. </p> <p> Tested on: </p> <p> BOOST_VERSION: 103800 BOOST_LIB_VERSION: 1_38 </p> <p> 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=<a class="ext-link" href="http://bugzilla.redhat.com/bugzilla"><span class="icon">​</span>http://bugzilla.redhat.com/bugzilla</a> --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-<span class="underline">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) </span></p> <p> Linux 2.6.27.24-170.2.68.fc10.x86_64 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> SMP x86_64 GNU/Linux </p> Ticket markboost@… Fri, 05 Jun 2009 20:55:41 GMT <link>https://svn.boost.org/trac10/ticket/2783#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2783#comment:2</guid> <description> <p> I disagree. (As does Jonathan Turkanis - <a class="ext-link" href="http://lists.boost.org/boost-users/2005/10/14362.php"><span class="icon">​</span>http://lists.boost.org/boost-users/2005/10/14362.php</a>). </p> <p> 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. </p> </description> <category>Ticket</category> </item> <item> <author>agander@…</author> <pubDate>Fri, 05 Jun 2009 21:32:13 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/2783#comment:3 https://svn.boost.org/trac10/ticket/2783#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <p> Ok, fair point. (Thats an embarassing start...) </p> Ticket Steven Watanabe Tue, 15 Jun 2010 02:52:45 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2783#comment:4 https://svn.boost.org/trac10/ticket/2783#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/62965" title="Throw an exception on an unexpected end of file in bzip2_decompressor ...">[62965]</a>) Throw an exception on an unexpected end of file in bzip2_decompressor instead of going into an infinite loop. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2783" title="#2783: Bugs: bzip2_decompressor infinite loops with truncated input file (closed: fixed)">#2783</a>. </p> Ticket