From owner-svn-src-all@FreeBSD.ORG Wed Jan 28 15:24:52 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 3B1DB390 for ; Wed, 28 Jan 2015 15:24:52 +0000 (UTC) Received: from nm5-vm0.bullet.mail.bf1.yahoo.com (nm5-vm0.bullet.mail.bf1.yahoo.com [98.139.213.150]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CC2CE1A3 for ; Wed, 28 Jan 2015 15:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1422458684; bh=NLBiZgQPth+/12ieN8JufKaBENBhOnkuLLTrEfV3Ueg=; h=Date:From:To:CC:Subject:References:In-Reply-To:From:Subject; b=cssPSnE6HTo/G0CpRikmkOBncAxDoUKs7sX0XJyqpgOvF5aalwW4sDWi2XNQCE9sF6RsW2y4FaPYjCFtem/HsNBXUcyt6p5st3TvHH7bKjn8GHCm+TEIrJpYRzj3nRvd3vxZmTZkLxAWLFBPBBe/210NxW6r8frTe0vbBscpVwd1aJ9bZvv9JeDbCYONVcxpwKt1UduiWEzaGoR/467D2qim3iz+Y4iZuWYbHsTdgSsC86g+j7Ilm8VyrhAfvDJrq8VwjvQQuxsIrwz5IkOz3DP0G77yvuHVD7JQBFmGaxViIRfSkyrafotovkAXXvsfMiFNrvAVo/WhZV1OEwX/sw== Received: from [66.196.81.174] by nm5.bullet.mail.bf1.yahoo.com with NNFMP; 28 Jan 2015 15:24:44 -0000 Received: from [98.139.211.202] by tm20.bullet.mail.bf1.yahoo.com with NNFMP; 28 Jan 2015 15:24:44 -0000 Received: from [127.0.0.1] by smtp211.mail.bf1.yahoo.com with NNFMP; 28 Jan 2015 15:24:44 -0000 X-Yahoo-Newman-Id: 702451.55031.bm@smtp211.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: I1YuD.MVM1m5SfG9HPv.uPf1lB7CrplqKO1OGPLchktG4X5 SbML114SFm8UO9VUdnOQS0nvvPAXpEHZsmsN3RhrlcF4BtYlSvlU6vvayBz. X64XC.Aa53L5boiHK.kgSjIo7M0jMCARetp8z8KNQlnK8cPtsDcySlpPiM87 8R2SSnjSL_xsEMJ05oIJs8pWq1NMVFxoeB52V_f9X_nzPp56B3IzYQP2G716 mmM_SQtmndOyRexDGeJGtacUNE0nDAEFSTM_elILD1qYzlKjZlU5It1y44pN ZswafVzmW9prk0tSZYdICyMYpqulwAzo9IOSKoBonCjEkDA_jL.2rNYzCs.2 QyF1EbnQ7hoIgzNdM_s3wqQLOFVctk6tdZ06MimwIdDWlZ0rCOH4GvL_rMGs J1OcB0fUOaXfE8vv7B5hae_lImmPHUYpr5Ty3fXpnWjyZTJsXViVAPeu1upi YpLHtEoG870AfMZpmOpnr6A5ezeLC2m230O9HEFaZoWOUlhGXLxQqyMLQlae DxOb8QTg_ICLbO.yTKmPqc133IptfYryGDc6_riCrPxN10s_xsdU_W6Ups4. M6.PrBpRN1M81d37B48UAulncQDxoHheNLduRVRZAA7hT.Dv4f07vnnXz3T6 q6Dawh8UxMG9_F9w8 X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Message-ID: <54C8FF53.5030709@FreeBSD.org> Date: Wed, 28 Jan 2015 10:25:07 -0500 From: Pedro Giffuni User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Bruce Evans Subject: Re: svn commit: r277802 - head/usr.bin/sed References: <201501271858.t0RIwO3n096590@svn.freebsd.org> <20150128190500.T1832@besplex.bde.org> In-Reply-To: <20150128190500.T1832@besplex.bde.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org 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: Wed, 28 Jan 2015 15:24:52 -0000 Hello; On 01/28/15 03:41, Bruce Evans wrote: > On Tue, 27 Jan 2015, Pedro F. Giffuni wrote: > >> Log: >> Fix resource leak and dereference after NULL. >> >> process.c: >> Protect access against NULL. >> >> main.c: >> Prevent outfile overwrite resource leak. >> ... >> Modified: head/usr.bin/sed/main.c >> ============================================================================== >> >> --- head/usr.bin/sed/main.c Tue Jan 27 18:56:46 2015 (r277801) >> +++ head/usr.bin/sed/main.c Tue Jan 27 18:58:24 2015 (r277802) >> @@ -411,6 +411,8 @@ mf_fgets(SPACE *sp, enum e_spflag spflag >> unlink(tmpfname); >> if ((outfile = fopen(tmpfname, "w")) == NULL) >> err(1, "%s", fname); >> + if (outfile != NULL && outfile != stdout) >> + fclose(outfile); >> fchown(fileno(outfile), sb.st_uid, sb.st_gid); >> fchmod(fileno(outfile), sb.st_mode & ALLPERMS); >> outfname = tmpfname; > > This is mismerged at best. It just breaks the new outfile by closing it. > The check in it makes no sense in this contents, since the freshly-opened > outfile cannot be NULL (since the open succeeded) or stdout (fopen() > cannot return a pointer to an already-open stream, so it can only return > stdout if the stdout pointer is garbage, but then it is not really > stdout). > Yes, I pasted the check after it was useful and not before like the original. I noticed right away and fixed it though: https://svnweb.freebsd.org/base?view=revision&revision=277811 But thanks for checking! Pedro.