[PATCH] msvcrt:msvcrt_get_flags: Fix bug 51846 - fopen(..., "wx")

Ted Lyngmo ted at lyncon.se
Thu Oct 7 13:22:22 CDT 2021


Hi Piotr and, wow, that's a quick reply

 >> With my patch, my test cases passes locally but TestBot says: >> 
file.c:119: Test failed: creating file with mode wx failed>>
file.c:129: Test failed: creating file with mode w+x failed >> The tests 
are failing on Windows.
Yeah, I tried that too now and indeed it fails there.

 > I've tried running them on fully updated Windows 10 and it also fails 
there. Is the 'x' format only supported in ucrtbase.dll (you have added 
the tests for msvcrt.dll)?

The change I've made to support the fopen() "x" mode is in 
"dlls/msvcrt/file.c"

It's supposed to extend all functions that uses msvcrt_get_flags() to 
support the "x" mode when opening files.

That's the only place where I could find "msvcrt_get_flags" which I 
searched for when running a program, that I had compiled with VS2019, in 
Wine. It printed:

0110:err:msvcrt:msvcrt_get_flags incorrect mode flag: x

.. and successfully overwrote the existing file. Really dangerous. When 
running that program in native WIndows, it does the right thing. The 
same VS2019-program also works as it should in Wine, with my patch.

I looked in "dlls/ucrtbase" - but there I could only find printf.c so I 
don't think it should be connected to this?

Tricky... / Ted



More information about the wine-devel mailing list