diff options
Diffstat (limited to 'gzio.c')
-rw-r--r-- | gzio.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -414,10 +414,14 @@ int ZEXPORT gzread (file, buf, len) | |||
414 | s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); | 414 | s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); |
415 | start = s->stream.next_out; | 415 | start = s->stream.next_out; |
416 | 416 | ||
417 | if (getLong(s) != s->crc || getLong(s) != s->stream.total_out) { | 417 | if (getLong(s) != s->crc) { |
418 | s->z_err = Z_DATA_ERROR; | 418 | s->z_err = Z_DATA_ERROR; |
419 | } else { | 419 | } else { |
420 | /* Check for concatenated .gz files: */ | 420 | (void)getLong(s); |
421 | /* The uncompressed length returned by above getlong() may | ||
422 | * be different from s->stream.total_out) in case of | ||
423 | * concatenated .gz files. Check for such files: | ||
424 | */ | ||
421 | check_header(s); | 425 | check_header(s); |
422 | if (s->z_err == Z_OK) { | 426 | if (s->z_err == Z_OK) { |
423 | uLong total_in = s->stream.total_in; | 427 | uLong total_in = s->stream.total_in; |
@@ -670,7 +674,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence) | |||
670 | return -1L; | 674 | return -1L; |
671 | #else | 675 | #else |
672 | if (whence == SEEK_SET) { | 676 | if (whence == SEEK_SET) { |
673 | offset -= s->stream.total_out; | 677 | offset -= s->stream.total_in; |
674 | } | 678 | } |
675 | if (offset < 0) return -1L; | 679 | if (offset < 0) return -1L; |
676 | 680 | ||
@@ -745,6 +749,7 @@ int ZEXPORT gzrewind (file) | |||
745 | s->z_eof = 0; | 749 | s->z_eof = 0; |
746 | s->stream.avail_in = 0; | 750 | s->stream.avail_in = 0; |
747 | s->stream.next_in = s->inbuf; | 751 | s->stream.next_in = s->inbuf; |
752 | s->crc = crc32(0L, Z_NULL, 0); | ||
748 | 753 | ||
749 | if (s->startpos == 0) { /* not a compressed file */ | 754 | if (s->startpos == 0) { /* not a compressed file */ |
750 | rewind(s->file); | 755 | rewind(s->file); |
@@ -793,7 +798,8 @@ local void putLong (file, x) | |||
793 | } | 798 | } |
794 | 799 | ||
795 | /* =========================================================================== | 800 | /* =========================================================================== |
796 | Reads a long in LSB order from the given gz_stream. Sets | 801 | Reads a long in LSB order from the given gz_stream. Sets z_err in case |
802 | of error. | ||
797 | */ | 803 | */ |
798 | local uLong getLong (s) | 804 | local uLong getLong (s) |
799 | gz_stream *s; | 805 | gz_stream *s; |