diff options
author | delphij <delphij@FreeBSD.org> | 2010-06-07 10:09:40 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2010-06-07 10:09:40 +0000 |
commit | f640e58a63bdf677750bdd45c86c12d2c8fe8dba (patch) | |
tree | 0a94a27bb1a70a77554d705e6b695fcc40790748 /usr.bin/gzip | |
parent | 39b40533818940f0d9a36492b6229edfc8b8d1b1 (diff) | |
download | FreeBSD-src-f640e58a63bdf677750bdd45c86c12d2c8fe8dba.zip FreeBSD-src-f640e58a63bdf677750bdd45c86c12d2c8fe8dba.tar.gz |
Correct a bug in gzip(1): make sure that initialize isb with fstat() on
input file before using it.
PR: bin/147275
Submitted by: thomas
MFC after: 1 week
Diffstat (limited to 'usr.bin/gzip')
-rw-r--r-- | usr.bin/gzip/gzip.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c index de9fe80..e9d3b20 100644 --- a/usr.bin/gzip/gzip.c +++ b/usr.bin/gzip/gzip.c @@ -1224,17 +1224,23 @@ file_compress(char *file, char *outfile, size_t outsize) return -1; } +#ifndef SMALL + if (fstat(in, &isb) != 0) { + maybe_warn("couldn't stat: %s", file); + close(in); + return -1; + } +#endif + if (cflag == 0) { #ifndef SMALL - if (fstat(in, &isb) == 0) { - if (isb.st_nlink > 1 && fflag == 0) { + if (isb.st_nlink != 1 && fflag == 0) { maybe_warnx("%s has %d other link%s -- " "skipping", file, isb.st_nlink - 1, isb.st_nlink == 1 ? "" : "s"); close(in); return -1; } - } if (fflag == 0 && (suff = check_suffix(file, 0)) && suff->zipped[0] != 0) { |