summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarco Pfatschbacher <mpf@cvs.openbsd.org>2008-08-20 09:22:03 +0000
committerMarco Pfatschbacher <mpf@cvs.openbsd.org>2008-08-20 09:22:03 +0000
commit80502d0aae5f4784171090c27164e6c4c1d04253 (patch)
tree49690555935f7e989e1a959407e3b63bc75dab85 /usr.bin
parente242c7f1340381864308a5a137ba278a474ed0d6 (diff)
Use and report errors that inflate(3) can return, instead of
aborting silently, and pretending everything went alright. This lets gzip(1) (especially gzip -t) detect truncated archives and curruptions that violate the structure of the zlib format. Unquiet compress(1) in zless/zmore, so the user has a chance to see errors on corrupted archives. OK millert@, markus@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/compress/gzopen.c13
-rw-r--r--usr.bin/compress/zmore6
2 files changed, 14 insertions, 5 deletions
diff --git a/usr.bin/compress/gzopen.c b/usr.bin/compress/gzopen.c
index 2e6d704c301..14c48595602 100644
--- a/usr.bin/compress/gzopen.c
+++ b/usr.bin/compress/gzopen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gzopen.c,v 1.24 2007/03/19 13:02:18 pedro Exp $ */
+/* $OpenBSD: gzopen.c,v 1.25 2008/08/20 09:22:02 mpf Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -60,7 +60,7 @@
#ifndef SMALL
const char gz_rcsid[] =
- "$OpenBSD: gzopen.c,v 1.24 2007/03/19 13:02:18 pedro Exp $";
+ "$OpenBSD: gzopen.c,v 1.25 2008/08/20 09:22:02 mpf Exp $";
#endif
#include <sys/param.h>
@@ -439,6 +439,15 @@ gz_read(void *cookie, char *buf, int len)
}
error = inflate(&(s->z_stream), Z_NO_FLUSH);
+
+ if (error == Z_DATA_ERROR) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (error == Z_BUF_ERROR) {
+ errno = EIO;
+ return -1;
+ }
if (error == Z_STREAM_END) {
/* Check CRC and original size */
s->z_crc = crc32(s->z_crc, start,
diff --git a/usr.bin/compress/zmore b/usr.bin/compress/zmore
index 93378fcc712..98522ef9da6 100644
--- a/usr.bin/compress/zmore
+++ b/usr.bin/compress/zmore
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $OpenBSD: zmore,v 1.5 2007/05/20 00:27:27 jsg Exp $
+# $OpenBSD: zmore,v 1.6 2008/08/20 09:22:02 mpf Exp $
#
# Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
#
@@ -47,13 +47,13 @@ fi
# No files means read from stdin
if [ $# -eq 0 ]; then
- compress -cdfq 2>&1 | $pager $flags
+ compress -cdf 2>&1 | $pager $flags
exit 0
fi
oterm=`stty -g 2>/dev/null`
while test $# -ne 0; do
- compress -cdfq "$1" 2>&1 | $pager $flags
+ compress -cdf "$1" 2>&1 | $pager $flags
prev="$1"
shift
if tty -s && test -n "$oterm" -a $# -gt 0; then