Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: [for consideration] TMPSUFFIX



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



Messages sorted by: Reverse Date, Date, Thread, Author