From eaf8e725e645818784a42445b4cd62ac35668fe7 Mon Sep 17 00:00:00 2001 From: gkoehler Date: Sat, 11 Nov 2023 02:52:55 +0000 Subject: [PATCH] Ignore -N in "gzip -dN # Copyright (c) 2017 Alexander Bluhm @@ -15,7 +15,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -CLEANFILES= *.gz rc rcmotd multi owner perm +CLEANFILES= *.gz rc rcmotd multi owner out perm # Test if gzip(1) detects truncated or corrupted files @@ -96,6 +96,29 @@ run-regress-multi: cat /etc/rc /etc/motd >rcmotd diff -up rcmotd multi +# Test -N + +REGRESS_TARGETS+= run-regress-name +run-regress-name: + @echo "\n==== $@ ====" + # check gunzip -N + gzip -c /etc/rc >in.gz + rm -f rc + gunzip -N in.gz + diff -up /etc/rc rc + # check that -N works with -l + gzip -c /etc/rc >in.gz + gzip -lN in.gz | grep -q ' rc$$' + gzip -lN out + diff -up /etc/rc out + # check that zcat ignores -N + rm -f out + zcat -N in.gz >out + diff -up /etc/rc out + # Test permissions REGRESS_TARGETS+= run-regress-perm-zip 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) { -- 2.20.1