https://bugs.winehq.org/show_bug.cgi?id=45935
Bug ID: 45935 Summary: Race condition in implementation of MoveFile, MoveFileEx, MoveFileWithProgress Product: Wine Version: 3.0.3 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: joshudson@gmail.com Distribution: ---
When using MoveFile (or any of its variants) to make unique file names, there is a race condition when two threads do so in the same directory.
We have commercial software that tries to do this.
path.c, line 1373 reads
if (rename( source_unix.Buffer, dest_unix.Buffer ) == -1)
Correct code:
if (renameat2( AT_FDCWD, source_unix.Buffer, AT_FDCWD, dest_unix.Buffer, (flag & MOVEFILE_REPLACE_EXISTING) ? 0 : RENAME_NOREPLACE ) == -1)
but you'll have to do a feature test for renameat2.