From owner-svn-src-all@FreeBSD.ORG Mon Jun 7 10:09:41 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8406C106566B; Mon, 7 Jun 2010 10:09:41 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 739598FC0C; Mon, 7 Jun 2010 10:09:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o57A9f86032308; Mon, 7 Jun 2010 10:09:41 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o57A9fgU032307; Mon, 7 Jun 2010 10:09:41 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201006071009.o57A9fgU032307@svn.freebsd.org> From: Xin LI Date: Mon, 7 Jun 2010 10:09:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208888 - head/usr.bin/gzip X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2010 10:09:41 -0000 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) {