[PATCH] msvcrt:msvcrt_get_flags: Fix bug 51846 - fopen(..., "wx")
Piotr Caban
piotr.caban at gmail.com
Thu Oct 7 13:49:04 CDT 2021
On 10/7/21 8:22 PM, Ted Lyngmo wrote:
> 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?
The msvcrt and ucrtbase dlls are sharing source. You can introduce
version specific behavior by guarding the code in dlls/msvcrt with #if
_MSVCR_VER>=140. In order to test the changes with ucrtbase.dll the
tests needs to go into dlls/ucrtbase/tests.
More information about the wine-devel
mailing list