From owner-svn-src-all@FreeBSD.ORG Sat Sep 18 00:46:06 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 0DA691065673; Sat, 18 Sep 2010 00:46:06 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F09BD8FC0A; Sat, 18 Sep 2010 00:46:05 +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 o8I0k5eY047015; Sat, 18 Sep 2010 00:46:05 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8I0k5MC047013; Sat, 18 Sep 2010 00:46:05 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201009180046.o8I0k5MC047013@svn.freebsd.org> From: Xin LI Date: Sat, 18 Sep 2010 00:46:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212808 - stable/7/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: Sat, 18 Sep 2010 00:46:06 -0000 Author: delphij Date: Sat Sep 18 00:46:05 2010 New Revision: 212808 URL: http://svn.freebsd.org/changeset/base/212808 Log: MFC r211475: Check return value of dup(), it could be -1 when the system is running out of file descriptors for instance. Found with: Coverity Prevent(tm) CID: 6084 Modified: stable/7/usr.bin/gzip/unpack.c Directory Properties: stable/7/usr.bin/gzip/ (props changed) Modified: stable/7/usr.bin/gzip/unpack.c ============================================================================== --- stable/7/usr.bin/gzip/unpack.c Sat Sep 18 00:44:55 2010 (r212807) +++ stable/7/usr.bin/gzip/unpack.c Sat Sep 18 00:46:05 2010 (r212808) @@ -312,7 +312,14 @@ unpack(int in, int out, char *pre, size_ { unpack_descriptor_t unpackd; - unpack_parse_header(dup(in), dup(out), pre, prelen, bytes_in, &unpackd); + in = dup(in); + if (in == -1) + maybe_err("dup"); + out = dup(out); + if (out == -1) + maybe_err("dup"); + + unpack_parse_header(in, out, pre, prelen, bytes_in, &unpackd); unpack_decode(&unpackd, bytes_in); unpack_descriptor_fini(&unpackd);