From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19285 invoked by alias); 26 Sep 2016 07:27:10 -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: 39441 Received: (qmail 3420 invoked from network); 26 Sep 2016 07:27:10 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.26):SA:0(0.0/5.0):. Processed in 0.607427 secs); 26 Sep 2016 07:27:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=5P2HV4Z/8258Aijur48lVWCGCMY=; b=t4zM7K x8ZOsfjg8mkN91gFawoT3yJG/W41fbZK1HTxOLaxhh+wLXJVL/78BYuapGE33zgj 4XOYxrxQFMoyt4oJPbTR+kP/mCShgNjtgmEZr7UPDtbRQE0TyKQoOFEULnqq+22P GfZxl2CS6wztsDo5rzJJlf0Z/wtzd/gVNUnag= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=5P2HV4Z/8258Aijur48lVWCGCMY=; b=rMBpm +gia9fSRzwCAxl+W7b+k+Y4CETD+eoQVSFr5c/6Uhfpdi1KcdCjEV2aDrdRQXLCV B5P7C4sghkJH9C8o0z51Qs+8L77pWceMHVt+AibgNnikC1ouvz0rz7pvkrhs1bvo 3tuSCJfOr+U8caHClMfFApi8z1kraBKn6xeiok= X-Sasl-enc: dUkF1yBZkA76sfqykDKRlHZ7GAnVBJOEDhQi2Xubjmwy 1474874818 Date: Mon, 26 Sep 2016 07:25:46 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: PATCH: [for consideration] TMPSUFFIX Message-ID: <20160926072546.GA28316@fujitsu.shahaf.local2> References: <160925155112.ZM23899@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <160925155112.ZM23899@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) Bart Schaefer wrote on Sun, Sep 25, 2016 at 15:51:12 -0700: > The addfilelist() is done whether or not we successfully opened the file, > because (a) it was that way before and (b) the name is returned either > way, so the caller might try to create the file itself. However, it > seems a bit odd that the failure of open() is mostly ignored? This looks like a race condition: if another process creates the filename that mktemp() returned before the open(O_EXCL) call [which will therefore fail], zsh will remove that filename even though zsh didn't create it. [This could trigger through a deliberate attack or through a race condition between two zsh instances calling =(:) concurrently.] I don't get "the caller will create the file". The =(:) syntax promises to expand to an existing filename with a defined content. How is it helpful to return a filename, which may or may not exist and certainly doesn't contain the output of 'cmd'? It seems to me erroring out would be better. (The caller can call getoutputfile() again if he wishes.) The patch creates two hard links to the file but only removes one of them. Cheers, Daniel