From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8438 invoked by alias); 10 Feb 2015 11:38:28 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34497 Received: (qmail 25051 invoked from network); 10 Feb 2015 11:38:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7fc86d0000066b7-97-54d9ed1cd39f Date: Tue, 10 Feb 2015 11:38:21 +0000 From: Peter Stephenson To: zsh workers Subject: Re: PATCH: Fix use-after-free for print -zf and print -sf Message-id: <20150210113821.36e1b7ed@pwslap01u.europe.root.pri> In-reply-to: References: <1423552346-18827-1-git-send-email-mikachu@gmail.com> <20150210093729.476bab46@pwslap01u.europe.root.pri> <20150210111811.1c851f7f@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplluLIzCtJLcpLzFFi42I5/e/4ZV2ZtzdDDF5PlbE42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGfMPT2Qu6OOoODytia2B8TZrFyMnh4SAicTv9T+YIGwxiQv3 1rN1MXJxCAksZZR4MmMPG0hCSGA5k8T7JicQm0VAVeLvjR52EJtNwFBi6qbZjCC2CFC8+fs/ FhBbWMBJYsmUZrChvAL2En3TzjKD2JwCwRKNX+ewQyxoYpZYN38iWDO/gL7E1b+foK6wl5h5 5QwjRLOgxI/J98CGMgtoSWze1sQKYctLbF7zlnkCo8AsJGWzkJTNQlK2gJF5FaNoamlyQXFS eq6RXnFibnFpXrpecn7uJkZIEH7dwbj0mNUhRgEORiUe3gtXboQIsSaWFVfmHmKU4GBWEuH9 +epmiBBvSmJlVWpRfnxRaU5q8SFGJg5OqQbGCUV8877ukoiYHMe7u+7IxerXmzmEmgqlVRym dh9YEW+hUv49+OiD/I6fKYXbjRm53zY/M07fvonzXsY+tYftgn9dI35M+sp+efaO8CsOqw6+ knNacYrt5NI5zf9uxB9wtpE9vVDLkE1hz0sj/lNvkx7dFBL6N33BjLc/5GsuzltneOVE69EN TEosxRmJhlrMRcWJAH1xvkIgAgAA On Tue, 10 Feb 2015 12:32:52 +0100 Mikael Magnusson wrote: > +#ifdef HAVE_OPEN_MEMSTREAM > + if (fout) > +#endif > + /* Testing EBADF special-cases >&- redirections */ > + if ((fout != stdout) ? (fclose(fout) != 0) : > + (fflush(fout) != 0 && errno != EBADF)) { > + zwarnnam(name, "write error: %e", errno); > + ret = 1; > + } This looks fine although based on experience I'd tend to write it as... #ifdef HAVE_OPEN_MEMSTREAM if (fout) #endif { /* Testing EBADF special-cases >&- redirections */ if ((fout != stdout) ? (fclose(fout) != 0) : (fflush(fout) != 0 && errno != EBADF)) { zwarnnam(name, "write error: %e", errno); ret = 1; } } for clarity. The braces are harmless without HAVE_OPEN_MEMSTREAM and explain the indentation --- otherwise you may well find lint or Coverity wailing they don't understand the indentation. (... anyone remember lint ...?) pws