https://bugs.winehq.org/show_bug.cgi?id=46255
Bug ID: 46255 Summary: BeginUpdateResourceW should set errno on invalid filename Product: Wine Version: 3.17 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: stu.axon@gmail.com Distribution: ---
BeginUpdateResourceW -- will return a Null handle if the filename is invalid but will not set a proper errorno (https://github.com/wine-mirror/wine/blob/master/dlls/kernel32/resource.c#L16...))
This bug was originally reported to pywin32-ctypes https://github.com/enthought/pywin32-ctypes/issues/59
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #1 from Janne janne.kekkonen@gmail.com --- Created attachment 79050 --> http://bugs.winehq.org/attachment.cgi?id=79050 BeginUpdateResourceW test application source.
Made simple test application which calls BeginUpdateResourceW.
Tested this application on Wine 10.9 and Windows 11. For the test I created file test2.txt to c:\temp\
In Windows 11 application prints following errors to console.
Ret val:0 LastError:2 Ret val:0 LastError:193 Ret val:0 LastError:87
In Wine first two gives following output: Ret val:0 LastError:0 Ret val:0 LastError:0
Third call with NULL as filename causes application to crash.
Application source is attached.
http://bugs.winehq.org/show_bug.cgi?id=46255
Maotong Zhang zmtong1988@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |zmtong1988@gmail.com
--- Comment #2 from Maotong Zhang zmtong1988@gmail.com --- Created attachment 79052 --> http://bugs.winehq.org/attachment.cgi?id=79052 Test patch
Please test it
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #3 from Maotong Zhang zmtong1988@gmail.com --- I will also take a look at EndUpdateResourceW and EnumResourceTypesW to see if they need fixing.
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #4 from Maotong Zhang zmtong1988@gmail.com --- Created attachment 79053 --> http://bugs.winehq.org/attachment.cgi?id=79053 Test patch
Please test 'EndupdateResourceW' The test program should ideally include BeginUpdateResource, EndUpdateResource, and EnumResourceTypesW. There is no issue with EnumResourceTypesW.
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #5 from Maotong Zhang zmtong1988@gmail.com --- https://bugs.winehq.org/show_bug.cgi?id=46254
http://bugs.winehq.org/show_bug.cgi?id=46255
Janne janne.kekkonen@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |janne.kekkonen@gmail.com
--- Comment #6 from Janne janne.kekkonen@gmail.com --- Applied patch to Wine10.12 and build it.
File c:\temp\test.txt do not exist. File c:\temp\test2.txt exists and it contains some text.
Here is output from application run in Wine.
WINEPREFIX=~/wine64 WINEARCH=win64 ~/wine64/wine --version
wine-10.12-91-ge44737278a4
WINEPREFIX=~/wine64 WINEARCH=win64 ~/wine64/wine beginupdate.exe
Ret val:0 LastError:2 Ret val:0 LastError:2 Ret val:0 LastError:87
Here is output or run in Windows11.
ver
Microsoft Windows [Version 10.0.26100.4652]
beginupdate.exe
Ret val:0 LastError:2 Ret val:0 LastError:193 Ret val:0 LastError:87
In step 2. there should be error code: ERROR_BAD_EXE_FORMAT returned by GetLastError.
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #7 from Maotong Zhang zmtong1988@gmail.com --- I ran your test program, but why are my results different from yours?
Both my Wine and Windows 11 give the same results. Ret val:00000000 LastError:2 Ret val:00000000 LastError:1006 Ret val:00000000 LastError:87 Could there be a difference in environment or test conditions?
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #8 from Janne janne.kekkonen@gmail.com --- (In reply to Maotong Zhang from comment #7)
I ran your test program, but why are my results different from yours?
Both my Wine and Windows 11 give the same results. Ret val:00000000 LastError:2 Ret val:00000000 LastError:1006 Ret val:00000000 LastError:87 Could there be a difference in environment or test conditions?
I noticed that if file exists but is empty then there is error 1006. Did you have empty test2.txt file in c:\temp directory?
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #9 from Maotong Zhang zmtong1988@gmail.com --- (In reply to Janne from comment #8)
(In reply to Maotong Zhang from comment #7)
I ran your test program, but why are my results different from yours?
Both my Wine and Windows 11 give the same results. Ret val:00000000 LastError:2 Ret val:00000000 LastError:1006 Ret val:00000000 LastError:87 Could there be a difference in environment or test conditions?
I noticed that if file exists but is empty then there is error 1006. Did you have empty test2.txt file in c:\temp directory?
The file is empty.
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #10 from Maotong Zhang zmtong1988@gmail.com --- Created attachment 79054 --> http://bugs.winehq.org/attachment.cgi?id=79054 Test2 patch
I have add the PE file check. Please test it again, thank you.
If the problem persists, could you please upload your test file?
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #11 from Janne janne.kekkonen@gmail.com --- Created attachment 79056 --> http://bugs.winehq.org/attachment.cgi?id=79056 test results
I applied all patches to Wine and recompiled it.
I also recompiled test application with these parameters: x86_64-w64-mingw32-gcc -Wall -g3 beginupdate.c -static -lkernel32 -o beginupdate_64.exe
Steps to reproduce situation in my system(s). Test 1: 1. Remove c:\temp\test.txt. 2. Create c:\temp\test2.txt, with some text. 3. Run application
Test 2: 1. Create empty file c:\temp\test.txt 2. Create c:\temp\test2.txt, with some text 3. Run application
Outputs seems to be identical on Windows 11 and Wine. Most likely i have made some errors on previous tests.
Outputs attached.
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #12 from Maotong Zhang zmtong1988@gmail.com --- Created attachment 79061 --> http://bugs.winehq.org/attachment.cgi?id=79061 Test3 patch
Modify the error code logic in EndUpdateResourceW
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #13 from Maotong Zhang zmtong1988@gmail.com --- A detailed test may be needed.
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #14 from Janne janne.kekkonen@gmail.com --- Tried to apply patch. But i got this error.
git apply -v test3.patch
test3.patch:29: trailing whitespace.
test3.patch:49: trailing whitespace. write_ret = write_raw_resources(updates); test3.patch:53: trailing whitespace. free_resource_directory( &updates->root, 2 ); Checking patch dlls/kernel32/resource.c... error: while searching for: BOOL WINAPI EndUpdateResourceW( HANDLE hUpdate, BOOL fDiscard ) { .....
http://bugs.winehq.org/show_bug.cgi?id=46255
--- Comment #15 from Maotong Zhang zmtong1988@gmail.com --- (In reply to Maotong Zhang from comment #4)
Created attachment 79053 [details] Test patch
Please test 'EndupdateResourceW' The test program should ideally include BeginUpdateResource, EndUpdateResource, and EnumResourceTypesW. There is no issue with EnumResourceTypesW.
Remove this patch
http://bugs.winehq.org/show_bug.cgi?id=46255
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, source, testcase