From 14763ac7c6c03bca62c39e35c03cf5bfc7728802 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Fri, 9 Sep 2011 23:20:29 -0700 Subject: zlib 1.1.3 --- gzio.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'gzio.c') diff --git a/gzio.c b/gzio.c index e29198a..f7c336a 100644 --- a/gzio.c +++ b/gzio.c @@ -414,10 +414,14 @@ int ZEXPORT gzread (file, buf, len) s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); start = s->stream.next_out; - if (getLong(s) != s->crc || getLong(s) != s->stream.total_out) { + if (getLong(s) != s->crc) { s->z_err = Z_DATA_ERROR; } else { - /* Check for concatenated .gz files: */ + (void)getLong(s); + /* The uncompressed length returned by above getlong() may + * be different from s->stream.total_out) in case of + * concatenated .gz files. Check for such files: + */ check_header(s); if (s->z_err == Z_OK) { uLong total_in = s->stream.total_in; @@ -670,7 +674,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence) return -1L; #else if (whence == SEEK_SET) { - offset -= s->stream.total_out; + offset -= s->stream.total_in; } if (offset < 0) return -1L; @@ -745,6 +749,7 @@ int ZEXPORT gzrewind (file) s->z_eof = 0; s->stream.avail_in = 0; s->stream.next_in = s->inbuf; + s->crc = crc32(0L, Z_NULL, 0); if (s->startpos == 0) { /* not a compressed file */ rewind(s->file); @@ -793,7 +798,8 @@ local void putLong (file, x) } /* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets + Reads a long in LSB order from the given gz_stream. Sets z_err in case + of error. */ local uLong getLong (s) gz_stream *s; -- cgit v1.2.3-55-g6feb