Opened 10 years ago
Last modified 8 years ago
#6994 new Bugs
gzip_decompressor issue with unusual files
Reported by: | Owned by: | Jonathan Turkanis | |
---|---|---|---|
Milestone: | To Be Determined | Component: | iostreams |
Version: | Boost 1.49.0 | Severity: | Problem |
Keywords: | gzip gzip_decompressor bgzip | Cc: |
Description
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:
$ 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
My file reading code is:
/* test.cpp */ #include <iostream> #include <boost/iostreams/filtering_stream.hpp> #include <boost/iostreams/filter/gzip.hpp> #include <boost/iostreams/copy.hpp> #include <boost/iostreams/device/file.hpp>
int main( int, char ) {
boost::iostreams::filtering_istream stream ; stream.push( boost::iostreams::gzip_decompressor() ) ; boost::iostreams::file_source file( argv[1] ) ; stream.push( file ) ; boost::iostreams::copy( stream, std::cout ) ;
}
Using gunzip on the above file works fine: $ gunzip -c ../hello.txt.bgz Hello, this is a test file.
Using the test program does not: $ ./test ../hello.txt.bgz terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::iostreams::gzip_error> >'
what(): gzip error
Attachments (2)
Change History (7)
comment:1 by , 10 years ago
by , 10 years ago
Attachment: | zlib_patch.txt added |
---|
by , 8 years ago
Attachment: | zlib_patch2.txt added |
---|
comment:3 by , 8 years ago
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.
comment:4 by , 8 years ago
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.
comment:5 by , 8 years ago
Keywords: | bgzip added |
---|
I was able to fix this with this patch:
--- 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 @@
+ crc_ = crc_imp_ = 0;