mirror of
https://github.com/openbsd/src.git
synced 2024-12-21 23:18:00 -08:00
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@
This commit is contained in:
parent
2deef9ff22
commit
eaf8e725e6
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.2 2017/06/22 16:10:34 bluhm Exp $
|
||||
# $OpenBSD: Makefile,v 1.3 2023/11/11 02:52:55 gkoehler Exp $
|
||||
|
||||
# Copyright (c) 2008 Marco Pfatschbacher <mpf@openbsd.org>
|
||||
# Copyright (c) 2017 Alexander Bluhm <bluhm@openbsd.org>
|
||||
@ -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 <in.gz | grep -q ' rc$$'
|
||||
# check that stdout ignores -N
|
||||
rm -f out
|
||||
gzip -dN <in.gz >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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user