diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-24 10:26:07 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-24 10:26:07 -0700 |
commit | a9ae24b6538a8c75b13826ef8a2547344fd2e08c (patch) | |
tree | 9f726be0a8f64c2a896d41683551d89b0e9a6611 /gzread.c | |
parent | 8824da8f01c63b0e77f96fe57faf762070bd0576 (diff) | |
download | zlib-a9ae24b6538a8c75b13826ef8a2547344fd2e08c.tar.gz zlib-a9ae24b6538a8c75b13826ef8a2547344fd2e08c.tar.bz2 zlib-a9ae24b6538a8c75b13826ef8a2547344fd2e08c.zip |
Change gzread() and related to ignore junk after gzip streams.
Previously the new gz* functions (introduced in 1.2.4) would read and
return raw data after the last gzip stream. This is inconsistent with
the behavior of gzip and the previous versions of zlib. Now when one
or more gzip streams have been decoded from the file, which is then
followed by data that is not a gzip stream (as detemined by not finding
the magic header), then that subsequent trailing garbage is ignored,
and no error is returned.
Diffstat (limited to 'gzread.c')
-rw-r--r-- | gzread.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -207,6 +207,15 @@ local int gz_head(state) | |||
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | /* no gzip header -- if we were decoding gzip before, then this is trailing | ||
211 | garbage. Ignore the trailing garbage and finish. */ | ||
212 | if (state->direct == 0) { | ||
213 | strm->avail_in = 0; | ||
214 | state->eof = 1; | ||
215 | state->have = 0; | ||
216 | return 0; | ||
217 | } | ||
218 | |||
210 | /* doing raw i/o, save start of raw data for seeking, copy any leftover | 219 | /* doing raw i/o, save start of raw data for seeking, copy any leftover |
211 | input to output -- this assumes that the output buffer is larger than | 220 | input to output -- this assumes that the output buffer is larger than |
212 | the input buffer, which also assures space for gzungetc() */ | 221 | the input buffer, which also assures space for gzungetc() */ |