Opened 11 years ago

Last modified 11 years ago

#5584 new Bugs

gzip_decompressor sometimes truncates data

Reported by: Hans-Andreas Engel <engel@…> Owned by: Jonathan Turkanis
Milestone: To Be Determined Component: iostreams
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

Th following trivial sample program boost_gunzip.cc only decompresses files partially. This issue only appears for a minority of the files.

#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>

#include <iostream>
#include <ios>

int main(int argc, const char *argv[]) {
    if (argc != 2) {
        std::cerr << "need exactly one argument" << std::endl;
        return 1;
    }

    boost::iostreams::filtering_istream in;
    in.push(boost::iostreams::gzip_decompressor());
    in.push(boost::iostreams::file_source(argv[1],
      std::ios_base::in | std::ios_base::binary));

    while (in.good()) {
        char c = in.get();
        if (in.good()) std::cout << c;
    }
};

In the following example, gzip_decompressor misses 113 bytes:

~$ cat <(for i in `seq 0 100`; do echo 'Mon May 30 23:17:43 EDT 2011'; done) > /tmp/a
~$ md5sum /tmp/a
040fce9cef21c343fd9ab2aecf1515e3  /tmp/a
~$ wc -c /tmp/a
2929 /tmp/a
~$ gzip /tmp/a
~$ md5sum /tmp/a.gz
46bd5683f86075e30124c5a6a1d2f83d  /tmp/a.gz

~$ zcat /tmp/a.gz | wc -c
2929
~$ ./boost_gunzip /tmp/a.gz | wc -c
2816

This is on a RHEL 6.1 64bit system, i.e., using boost-iostreams-1.41.0-11.el6.x86_64.

Attachments (1)

a.gz (76 bytes ) - added by Hans-Andreas Engel <engel@…> 11 years ago.
Compressed file a.gz causing truncated reads

Download all attachments as: .zip

Change History (3)

by Hans-Andreas Engel <engel@…>, 11 years ago

Attachment: a.gz added

Compressed file a.gz causing truncated reads

comment:1 by anonymous, 11 years ago

Looks like this doesn't affect latest trunk.

ivan@ivan-desktop:~/iostreams-test$ cat <(for i in `seq 0 100`; do echo 'Mon May 30 23:17:43 EDT 2011'; done) > a
ivan@ivan-desktop:~/iostreams-test$ wc -c a
2929 a
ivan@ivan-desktop:~/iostreams-test$ gzip a
ivan@ivan-desktop:~/iostreams-test$ zcat a.gz | wc -c
2929
ivan@ivan-desktop:~/iostreams-test$ ./boost_gunzip a.gz | wc -c
2929

trunk r72410. ubuntu 11.04 x64

comment:2 by Steven Watanabe, 11 years ago

Component: Noneiostreams
Owner: set to Jonathan Turkanis
Note: See TracTickets for help on using tickets.