X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=zlib%2Fgzio.c;h=f7c336a55a0911bdd45fcd9caa10c8570b3c5d6c;hb=39521df546830fec63ee1847d9e1c13e4cc3150c;hp=e29198ac7afaf76999c0c6e00908005cb12a4d68;hpb=6dd8a1525c2e3981ceaec30982b584d67a21d897;p=simgear.git diff --git a/zlib/gzio.c b/zlib/gzio.c index e29198ac..f7c336a5 100644 --- a/zlib/gzio.c +++ b/zlib/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;