From owner-svn-src-head@freebsd.org Mon Jul 9 06:19:34 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 012621048068; Mon, 9 Jul 2018 06:19:34 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A7D4D83662; Mon, 9 Jul 2018 06:19:33 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 84086113A8; Mon, 9 Jul 2018 06:19:33 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w696JXds089733; Mon, 9 Jul 2018 06:19:33 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w696JXOv089732; Mon, 9 Jul 2018 06:19:33 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201807090619.w696JXOv089732@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 9 Jul 2018 06:19:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336121 - head/usr.bin/gzip X-SVN-Group: head X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: head/usr.bin/gzip X-SVN-Commit-Revision: 336121 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2018 06:19:34 -0000 Author: delphij Date: Mon Jul 9 06:19:33 2018 New Revision: 336121 URL: https://svnweb.freebsd.org/changeset/base/336121 Log: Don't delete outfile unconditionally. MFC after: 1 month Modified: head/usr.bin/gzip/gzip.c Modified: head/usr.bin/gzip/gzip.c ============================================================================== --- head/usr.bin/gzip/gzip.c Mon Jul 9 06:02:45 2018 (r336120) +++ head/usr.bin/gzip/gzip.c Mon Jul 9 06:19:33 2018 (r336121) @@ -1429,6 +1429,7 @@ file_uncompress(char *file, char *outfile, size_t outs unsigned char header1[4]; enum filetype method; int fd, ofd, zfd = -1; + int err; size_t in_size; #ifndef SMALL ssize_t rv; @@ -1601,14 +1602,21 @@ file_uncompress(char *file, char *outfile, size_t outs size = zuncompress(in, out, NULL, 0, NULL); /* need to fclose() if ferror() is true... */ - if (ferror(in) | fclose(in)) { - maybe_warn("failed infile fclose"); - unlink(outfile); + err = ferror(in); + if (err | fclose(in)) { + if (err) + maybe_warn("failed infile"); + else + maybe_warn("failed infile fclose"); + if (cflag == 0) + unlink(outfile); (void)fclose(out); + goto lose; } if (fclose(out) != 0) { maybe_warn("failed outfile fclose"); - unlink(outfile); + if (cflag == 0) + unlink(outfile); goto lose; } break;