summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorGeorge Koehler <gkoehler@cvs.openbsd.org>2023-11-11 02:52:56 +0000
committerGeorge Koehler <gkoehler@cvs.openbsd.org>2023-11-11 02:52:56 +0000
commit3045c97d9af3d59bb3ff728adda25048e9f40954 (patch)
treefbb069220c31801ebdb68f2285628ffa4fb1f62b /usr.bin
parent689a5a7797d6edc0e34d79a1d9f538d645509249 (diff)
Ignore -N in "gzip -dN <in.gz" and "zcat -N in.gz"
Have -c override -N, like other gzip implementations. Before, our -N (decompress to stored name) overrode -c (cat to stdout) and crashed with a pledge violation, because the pledge for -c excludes wpath. Guilherme Janczak reported the pledge violation in July 2022 and provided a diff to prevent it, along with a regress test. I rewrote the diff and expanded the regress. ok kn@ millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/compress/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c
index 834f3bd90d3..e6f4f8f4b99 100644
--- a/usr.bin/compress/main.c
+++ b/usr.bin/compress/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.105 2023/08/11 04:45:05 guenther Exp $ */
+/* $OpenBSD: main.c,v 1.106 2023/11/11 02:52:55 gkoehler Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -699,7 +699,8 @@ dodecompress(const char *in, char *out, struct stat *sb)
close (ifd);
return (FAILURE);
}
- if (storename && oldname[0] != '\0') {
+ /* Ignore -N when decompressing to stdout. */
+ if (storename && (!cat || list) && oldname[0] != '\0') {
const char *oldbase = basename(oldname);
char *cp = strrchr(out, '/');
if (cp != NULL) {
@@ -707,7 +708,6 @@ dodecompress(const char *in, char *out, struct stat *sb)
strlcat(out, oldbase, PATH_MAX);
} else
strlcpy(out, oldbase, PATH_MAX);
- cat = 0; /* XXX should -c override? */
}
if (testmode) {