From owner-svn-src-all@FreeBSD.ORG Fri Jan 30 14:38:00 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 69C76263; Fri, 30 Jan 2015 14:38:00 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 55E1E278; Fri, 30 Jan 2015 14:38:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0UEc06T067580; Fri, 30 Jan 2015 14:38:00 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0UEbxdQ067569; Fri, 30 Jan 2015 14:37:59 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201501301437.t0UEbxdQ067569@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Fri, 30 Jan 2015 14:37:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r277934 - stable/9/usr.bin/sed X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 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: Fri, 30 Jan 2015 14:38:00 -0000 Author: pfg Date: Fri Jan 30 14:37:59 2015 New Revision: 277934 URL: https://svnweb.freebsd.org/changeset/base/277934 Log: MFC r277802, r277811: sed: Fix resource leak and dereference after NULL. process.c: Protect access against NULL. main.c: Prevent outfile overwrite resource leak. CID: 271181 CID: 1006930 Obtained from: NetBSD Modified: stable/9/usr.bin/sed/main.c stable/9/usr.bin/sed/process.c Directory Properties: stable/9/usr.bin/sed/ (props changed) Modified: stable/9/usr.bin/sed/main.c ============================================================================== --- stable/9/usr.bin/sed/main.c Fri Jan 30 14:36:02 2015 (r277933) +++ stable/9/usr.bin/sed/main.c Fri Jan 30 14:37:59 2015 (r277934) @@ -404,6 +404,8 @@ mf_fgets(SPACE *sp, enum e_spflag spflag if (len >= sizeof(tmpfname)) errx(1, "%s: name too long", fname); unlink(tmpfname); + if (outfile != NULL && outfile != stdout) + fclose(outfile); if ((outfile = fopen(tmpfname, "w")) == NULL) err(1, "%s", fname); fchown(fileno(outfile), sb.st_uid, sb.st_gid); Modified: stable/9/usr.bin/sed/process.c ============================================================================== --- stable/9/usr.bin/sed/process.c Fri Jan 30 14:36:02 2015 (r277933) +++ stable/9/usr.bin/sed/process.c Fri Jan 30 14:37:59 2015 (r277934) @@ -314,7 +314,7 @@ applies(struct s_command *cp) } else r = 1; } - } else if (MATCH(cp->a1)) { + } else if (cp->a1 && MATCH(cp->a1)) { /* * If the second address is a number less than or * equal to the line number first selected, only