http://bugs.winehq.org/show_bug.cgi?id=21086
Summary: Bug in SearchPath when filename supplied but null Product: Wine Version: 1.1.35 Platform: x86 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: kernel32 AssignedTo: wine-bugs@winehq.org ReportedBy: us@edmeades.me.uk
Debugging a private application shows that SearchPath on wine returns success incorrectly when passed a filename which is a valid pointer but points to a null character.
I have a standalone testcase for this which is trivial to put into the main wine testsuite, and I have also confirmed that a simple check for [0]==0x00 in SearchPathW in kernel32/path.c and setting last error of 87 (invalid parameter) and returning 0 fixes the problem in my application.
JECC
http://bugs.winehq.org/show_bug.cgi?id=21086
--- Comment #1 from Jason Edmeades us@edmeades.me.uk 2009-12-19 18:07:29 --- Created an attachment (id=25290) --> (http://bugs.winehq.org/attachment.cgi?id=25290) Simple standalone testcase
http://bugs.winehq.org/show_bug.cgi?id=21086
--- Comment #2 from Jason Edmeades us@edmeades.me.uk 2009-12-19 18:07:44 --- Created an attachment (id=25291) --> (http://bugs.winehq.org/attachment.cgi?id=25291) Compiled exe on windows
http://bugs.winehq.org/show_bug.cgi?id=21086
--- Comment #3 from Jason Edmeades us@edmeades.me.uk 2009-12-19 18:09:08 --- (And to answer the obvious follow on question, I will submit this test as a patch to the kernel32 tests as soon as I get a chance if noone beats me to it, but it may be a while as I have some remaining bugs to identify)
http://bugs.winehq.org/show_bug.cgi?id=21086
--- Comment #4 from Nikolay Sivov bunglehead@gmail.com 2009-12-20 10:01:04 --- (In reply to comment #1)
Created an attachment (id=25290)
--> (http://bugs.winehq.org/attachment.cgi?id=25290) [details]
Simple standalone testcase
Hi, Jason.
You're doing it wrong: --- rc = SearchPath("c:\windows", &filename, 0, 256, &buffer, &ptr); --- Should be: --- rc = SearchPath("c:\windows", filename, 0, 256, buffer, &ptr); ---
Is it a typo?
http://bugs.winehq.org/show_bug.cgi?id=21086
--- Comment #5 from Nikolay Sivov bunglehead@gmail.com 2009-12-20 14:43:57 --- Created an attachment (id=25312) --> (http://bugs.winehq.org/attachment.cgi?id=25312) Possible testcase
Is it what you mean? If so, yes, this test fails in Wine but don't on Windows.
http://bugs.winehq.org/show_bug.cgi?id=21086
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, testcase
http://bugs.winehq.org/show_bug.cgi?id=21086
--- Comment #6 from Jason Edmeades us@edmeades.me.uk 2009-12-20 15:15:28 --- Yes, sorry... exactly...! On wine the SearchPath with no filename succeeds and the app in question then tries to fopen the file, which fails as its trying to open a directory!
Pasted here is a patch which solves the problem for my app and I think its the simplest solution. (I would attach it as a patch but its cut and pasted from a document I was maintaining for the app in question). Can you see if it makes the test pass please (feel free to submit it, otherwise I'll try to send it in when I get back to work and can get a proper patch file).
--- a/dlls/kernel32/path.c +++ b/dlls/kernel32/path.c @@ -753,6 +753,11 @@ DWORD WINAPI SearchPathW( LPCWSTR path, LPCWSTR name, LPCWSTR ext, DWORD buflen, DWORD ret = 0;
/* If the name contains an explicit path, ignore the path */ + if (name && name[0] == 0x00) { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + }
http://bugs.winehq.org/show_bug.cgi?id=21086
--- Comment #7 from Nikolay Sivov bunglehead@gmail.com 2009-12-20 15:29:36 --- (In reply to comment #6)
Pasted here is a patch which solves the problem for my app and I think its the simplest solution. (
Not so fast, this function has no tests currently, and no primitive parameter validation (null checks), so a bunch of tests needed first. I'll work on it. Your fix is unacceptable without tests anyway, just keep it in local repo if it helps, and stay tuned.
http://bugs.winehq.org/show_bug.cgi?id=21086
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #8 from Nikolay Sivov bunglehead@gmail.com 2009-12-22 10:09:19 --- This is fixed by commit 6d270a1d48c193a40c5145758053b6083627fb2f.
http://bugs.winehq.org/show_bug.cgi?id=21086
Jeff Zaroyko jeffz@jeffz.name changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #9 from Jeff Zaroyko jeffz@jeffz.name 2010-01-09 04:43:48 --- Closing bugs fixed in 1.1.36.