diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2005-07-11 14:16:48 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2005-07-11 14:16:48 +0000 |
commit | f9adc169c4738b9fe1a7287ab8db6e1b6778f1c7 (patch) | |
tree | 56f8be2e0533c505773d0de818bb39f0977933fb | |
parent | 0d9672554500c375b104b67c7519529649740e46 (diff) |
Don't set timestamps created from stack garbage when compressing
from stdin. Based on a patch from marc@
-rw-r--r-- | usr.bin/compress/main.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c index 3cd67fa812b..45987f3ffb3 100644 --- a/usr.bin/compress/main.c +++ b/usr.bin/compress/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.63 2005/06/26 18:20:26 otto Exp $ */ +/* $OpenBSD: main.c,v 1.64 2005/07/11 14:16:47 millert Exp $ */ #ifndef SMALL static const char copyright[] = @@ -36,7 +36,7 @@ static const char license[] = #endif /* SMALL */ #ifndef SMALL -static const char main_rcsid[] = "$OpenBSD: main.c,v 1.63 2005/06/26 18:20:26 otto Exp $"; +static const char main_rcsid[] = "$OpenBSD: main.c,v 1.64 2005/07/11 14:16:47 millert Exp $"; #endif #include <sys/param.h> @@ -468,7 +468,7 @@ docompress(const char *in, char *out, const struct compressor *method, if ((ifd = open(in, O_RDONLY)) < 0) { if (verbose >= 0) - warn("%s", out); + warn("%s", in); return (FAILURE); } @@ -681,13 +681,6 @@ setfile(const char *name, int fd, struct stat *fs) if (name == NULL || cat || testmode) return; - if (!pipin || !nosave) { - TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec); - TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec); - if (futimes(fd, tv)) - warn("futimes: %s", name); - } - /* * If input was a pipe we don't have any info to restore but we * must set the mode since the current mode on the file is 0200. @@ -716,6 +709,13 @@ setfile(const char *name, int fd, struct stat *fs) if (fs->st_flags && fchflags(fd, fs->st_flags)) warn("fchflags: %s", name); + + if (!nosave) { + TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec); + TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec); + if (futimes(fd, tv)) + warn("futimes: %s", name); + } } int |