Boost C++ Libraries: Ticket #6994: gzip_decompressor issue with unusual files https://svn.boost.org/trac10/ticket/6994 <p> The gzip_decompressor implementation fails on gzip files that contain an empty block after a non-empty one. (You can make such a file by gzipping a nonempty and an empty file and concatenating them, but they are also sometimes written by other tools.) Here such a file: </p> <p> $ hexdump -C hello.txt.gz 00000000 1f 8b 08 00 0d ea b4 4f 00 03 cb 48 cd c9 c9 57 |.......O...H...W| 00000010 28 c9 48 2d 4a e5 02 00 8e 45 d1 59 0c 00 00 00 |(.H-J....E.Y....| 00000020 1f 8b 08 00 18 ea b4 4f 00 03 03 00 00 00 00 00 |.......O........| 00000030 00 00 00 00 |....| 00000034 </p> <p> My file reading code is: </p> <p> /* test.cpp */ #include &lt;iostream&gt; #include &lt;boost/iostreams/filtering_stream.hpp&gt; #include &lt;boost/iostreams/filter/gzip.hpp&gt; #include &lt;boost/iostreams/copy.hpp&gt; #include &lt;boost/iostreams/device/file.hpp&gt; </p> <p> int main( int, char<strong> ) { </strong></p> <blockquote> <p> boost::iostreams::filtering_istream stream ; stream.push( boost::iostreams::gzip_decompressor() ) ; boost::iostreams::file_source file( argv<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a> ) ; stream.push( file ) ; boost::iostreams::copy( stream, std::cout ) ; </p> </blockquote> <p> } </p> <p> Using gunzip on the above file works fine: $ gunzip -c ../hello.txt.bgz Hello, this is a test file. </p> <p> Using the test program does not: $ ./test ../hello.txt.bgz terminate called after throwing an instance of 'boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::iostreams::gzip_error&gt; &gt;' </p> <blockquote> <p> what(): gzip error </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6994 Trac 1.4.3 Gavin Band <gavinband@…> Mon, 18 Jun 2012 08:49:06 GMT <link>https://svn.boost.org/trac10/ticket/6994#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6994#comment:1</guid> <description> <p> I was able to fix this with this patch: </p> <p> --- libs/iostreams/src/zlib.cpp 2012-06-18 09:45:42.000000000 +0100 +++ libs/iostreams/src/zlib.cpp.new 2012-06-18 09:45:23.000000000 +0100 @@ -150,7 +150,7 @@ </p> <blockquote> <p> (compress ? deflateEnd(s) : inflateEnd(s)) </p> <blockquote> <p> ; </p> </blockquote> </blockquote> <blockquote> <p> <em>); </em></p> </blockquote> <ul><li> crc_imp_ = 0; </li></ul><p> + crc_ = crc_imp_ = 0; </p> <blockquote> <p> } </p> </blockquote> <p> </p> <blockquote> <p> void zlib_base::do_init </p> </blockquote> </description> <category>Ticket</category> </item> <item> <author>Gavin Band <gavinband@…></author> <pubDate>Mon, 18 Jun 2012 08:52:50 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6994 https://svn.boost.org/trac10/ticket/6994 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">zlib_patch.txt</span> </li> </ul> Ticket Gavin Band <gavinband@…> Mon, 18 Jun 2012 08:53:25 GMT <link>https://svn.boost.org/trac10/ticket/6994#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6994#comment:2</guid> <description> <p> I've attached the patch as well, as it's badly formatted above. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 03 Nov 2014 15:47:38 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6994 https://svn.boost.org/trac10/ticket/6994 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">zlib_patch2.txt</span> </li> </ul> Ticket gavinband Mon, 03 Nov 2014 15:48:52 GMT <link>https://svn.boost.org/trac10/ticket/6994#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6994#comment:3</guid> <description> <p> I've added a second patch (zlib_patch2.txt) against boost 1.55 which, for me, fixes the decompression without breaking compression. This really needs a maintainer to look at it to confirm suitability though. </p> </description> <category>Ticket</category> </item> <item> <author>wkretzsch@…</author> <pubDate>Mon, 02 Mar 2015 14:18:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6994#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6994#comment:4</guid> <description> <p> I am running into this issue as well with boost 1.57. It would be great to have this patch brought into the main code base. </p> </description> <category>Ticket</category> </item> <item> <author>wkretzsch@…</author> <pubDate>Mon, 02 Mar 2015 14:22:00 GMT</pubDate> <title>keywords changed https://svn.boost.org/trac10/ticket/6994#comment:5 https://svn.boost.org/trac10/ticket/6994#comment:5 <ul> <li><strong>keywords</strong> bgzip added </li> </ul> Ticket