#5908 closed Bugs (fixed)
iostreams gzip fails to handle optional extra fields in gzip header
Reported by: | Owned by: | Jonathan Turkanis | |
---|---|---|---|
Milestone: | To Be Determined | Component: | iostreams |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | gzip | Cc: |
Description
When bit 2 (FEXTRA) is set in a gzip header's flags, the iostreams code fails to read the XLEN field before starting to read the extra comment. The code is actually there to do it, but it gets skipped. This means the code goes directly a loop like: while (--xlen != 0) with xlen still set to 0. This results in the rest of the file being slurped in by this comment reading code (or at least until xlen wraps around to 0 again, which could take awhile). I ran into this because many popular file formats in bioinformatics (BAM, tabix) are gzipped and include extra optional fields in their headers.
I've attached an example gzipped file with an optional header, a test program that should demonstrate the problem (against 1.47 and latest svn), as well as a patch that fixes it.
Attachments (4)
Change History (12)
by , 11 years ago
Attachment: | sample.txt.gz added |
---|
by , 11 years ago
Attachment: | example.cpp added |
---|
test case that demonstrates the problem (run ./example sample.txt.gz)
by , 11 years ago
Attachment: | iostreams-gzip.patch added |
---|
patch that fixes the issue (patch -p0 < iostreams-gzip.patch from top level of the repo)
comment:1 by , 11 years ago
Seems like this is still present in 1.48 and current SVN. To be clear, the sample file is not empty. The desired output would be for the test program to read "hello there", but it gets nothing. You can compare to gzip -dc. The supplied patch still works with current SVN.
comment:2 by , 11 years ago
Also worth mentioning is that this worked in 1.40, but when the ability to support multiple compressed objects in 1 gzipped stream was introduced, this bug appeared.
by , 11 years ago
Attachment: | iostreams-gzip_hdr_test.patch added |
---|
second patch adding unit test to prevent future regressions.
comment:3 by , 11 years ago
The test attached in the second patch (iostreams-gzip_hdr_test.patch) will fail with the current code, demonstrating the inability to parse certain types of RFC 1952 compliant gzip headers. Application of the first patch will cause the test to pass.
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:6 by , 6 years ago
Component: | iostreams → xpressive |
---|---|
Milestone: | To Be Determined → Website 1.X |
Resolution: | fixed |
Severity: | Problem → Not Applicable |
Status: | closed → reopened |
Type: | Bugs → Library Submissions |
Version: | Boost 1.47.0 → Boost.Build-M3 |
Hi. Only wanted to ask a quick issue. Now i am eaadkebdkckdgfgd
comment:7 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:8 by , 6 years ago
Component: | xpressive → iostreams |
---|---|
Milestone: | Website 1.X → To Be Determined |
Severity: | Not Applicable → Problem |
Type: | Library Submissions → Bugs |
Version: | Boost.Build-M3 → Boost 1.47.0 |
gzip file with extra comment in header