diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/compress/gzopen.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/usr.bin/compress/gzopen.c b/usr.bin/compress/gzopen.c index c0893a0bb19..6e701d4118a 100644 --- a/usr.bin/compress/gzopen.c +++ b/usr.bin/compress/gzopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gzopen.c,v 1.14 2003/07/17 20:17:02 mickey Exp $ */ +/* $OpenBSD: gzopen.c,v 1.15 2003/11/14 22:29:53 millert Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -59,7 +59,7 @@ */ const char gz_rcsid[] = - "$OpenBSD: gzopen.c,v 1.14 2003/07/17 20:17:02 mickey Exp $"; + "$OpenBSD: gzopen.c,v 1.15 2003/11/14 22:29:53 millert Exp $"; #include <sys/param.h> #include <sys/stat.h> @@ -443,8 +443,22 @@ gz_read(void *cookie, char *buf, int len) } s->z_crc = crc32(s->z_crc, start, (uInt)(s->z_stream.next_out - start)); + len -= s->z_stream.avail_out; - return (int)(len - s->z_stream.avail_out); + /* If at EOF, check for another appended file. */ + if (s->z_eof) { + int ocrc = s->z_crc; + s->z_crc = crc32(0L, Z_NULL, 0); + s->z_eof = 0; + if (get_header(s, NULL, 0) != 0 || + inflateEnd(&s->z_stream) != Z_OK || + inflateInit2(&s->z_stream, -MAX_WBITS) != Z_OK) { + s->z_eof = 1; + s->z_crc = ocrc; + } + } + + return (len); } int |