Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jun 2010 10:09:41 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r208888 - head/usr.bin/gzip
Message-ID:  <201006071009.o57A9fgU032307@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Mon Jun  7 10:09:40 2010
New Revision: 208888
URL: http://svn.freebsd.org/changeset/base/208888

Log:
  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

Modified:
  head/usr.bin/gzip/gzip.c

Modified: head/usr.bin/gzip/gzip.c
==============================================================================
--- head/usr.bin/gzip/gzip.c	Mon Jun  7 08:23:16 2010	(r208887)
+++ head/usr.bin/gzip/gzip.c	Mon Jun  7 10:09:40 2010	(r208888)
@@ -1224,17 +1224,23 @@ file_compress(char *file, char *outfile,
 		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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006071009.o57A9fgU032307>