src/fileio.c : vim_tempname() contains these lines:

    if (GetTempFileName(szTempFile, buf4, 0, itmp) == 0)
        return NULL;
    /* GetTempFileName() will create the file, we don't want that */
    (void)DeleteFile(itmp);

Is this really right?  Is there any reason to call DeleteFile() here?
On a quick glance, it seems that everyone who gets a name back is just
doing an mch_open(tempname, "w") on it, which doesn't care whether or
not the file exists already.

I ask because this seems to be causing a race condition:
GetTempFileName() checks if a file exists, finds a name that doesn't
exist, creates it, and returns the name back to the caller.  It
creates it so that future calls to GetTempFileName() won't choose the
same file, since it now exists.  But, deleting it before being done
with it introduces a race condition: vim calls GetTempFileName(), then
DeleteFile(), then another process calls GetTempFileName(), and now
vim has the path to a file that didn't exist when it asked for a
unique, non-existant file, but exists now, and is no longer safe for
vim to use.

~Matt

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui