summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-11-21 21:54:47 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-11-21 21:54:47 +0000
commitaa5041bef1ff06259db3a1da70c75d0d858c877f (patch)
tree5dee5fc293b8993723d65710b794fe562297c228 /usr.bin
parentc87ab46eedc2039bba88e3e81f6bfd2620a03515 (diff)
Simplified support for concatenated files; similar to what zlib does.
mickey@ OK
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/compress/gzopen.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/usr.bin/compress/gzopen.c b/usr.bin/compress/gzopen.c
index 6e701d4118a..0527d172b1b 100644
--- a/usr.bin/compress/gzopen.c
+++ b/usr.bin/compress/gzopen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gzopen.c,v 1.15 2003/11/14 22:29:53 millert Exp $ */
+/* $OpenBSD: gzopen.c,v 1.16 2003/11/21 21:54:46 millert Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -59,7 +59,7 @@
*/
const char gz_rcsid[] =
- "$OpenBSD: gzopen.c,v 1.15 2003/11/14 22:29:53 millert Exp $";
+ "$OpenBSD: gzopen.c,v 1.16 2003/11/21 21:54:46 millert Exp $";
#include <sys/param.h>
#include <sys/stat.h>
@@ -437,27 +437,19 @@ gz_read(void *cookie, char *buf, int len)
return -1;
}
s->z_hlen += 2 * sizeof(int32_t);
- s->z_eof = 1;
- break;
+ /* Check for the existence of an appended file. */
+ if (get_header(s, NULL, 0) != 0) {
+ s->z_eof = 1;
+ break;
+ }
+ inflateReset(&(s->z_stream));
+ s->z_crc = crc32(0L, Z_NULL, 0);
}
}
s->z_crc = crc32(s->z_crc, start,
(uInt)(s->z_stream.next_out - start));
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);
}