summaryrefslogtreecommitdiff
path: root/usr.bin/compress/main.c
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1998-03-10 16:34:04 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1998-03-10 16:34:04 +0000
commitc3291349fef87571336ccbf84a30fa3da2c425a8 (patch)
treea8c82f093731d936558f68595f03f527baff6bb0 /usr.bin/compress/main.c
parentde519d89d24e51f5ee63596df13875bf2da564f8 (diff)
fix coredump on pipe to uncompress
Diffstat (limited to 'usr.bin/compress/main.c')
-rw-r--r--usr.bin/compress/main.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c
index 49ff1e263d3..209c3ffe7b6 100644
--- a/usr.bin/compress/main.c
+++ b/usr.bin/compress/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.8 1998/02/13 16:36:24 millert Exp $ */
+/* $OpenBSD: main.c,v 1.9 1998/03/10 16:34:03 mickey Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)compress.c 8.2 (Berkeley) 1/7/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.8 1998/02/13 16:36:24 millert Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.9 1998/03/10 16:34:03 mickey Exp $";
#endif
#endif /* not lint */
@@ -61,7 +61,7 @@ static char rcsid[] = "$OpenBSD: main.c,v 1.8 1998/02/13 16:36:24 millert Exp $"
#define min(a,b) ((a) < (b)? (a) : (b))
-int force = 0, verbose = 0, testmode = 0, list = 0, nosave = 0;
+int pipin = 0, force = 0, verbose = 0, testmode = 0, list = 0, nosave = 0;
extern char *__progname;
struct compressor {
@@ -245,8 +245,10 @@ main(argc, argv)
}
}
}
- } else
+ } else {
infile = "/dev/stdin";
+ pipin++;
+ }
if (testmode)
strcpy(outfile, _PATH_DEVNULL);
@@ -410,7 +412,6 @@ decompress(in, out, method, bits)
int error;
error = 0;
- method = NULL;
cookie = NULL;
if ((ifd = open(in, O_RDONLY)) < 0) {
@@ -427,7 +428,7 @@ decompress(in, out, method, bits)
return -1;
}
- if ((method = check_method(ifd, out)) == NULL) {
+ if (!pipin && (method = check_method(ifd, out)) == NULL) {
if (verbose >= 0)
warnx("%s: unrecognized file format", in);
return -1;