Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49285 Signed-off-by: Fabian Maurer dark.shadow4@web.de
-- v2: kernel32: In WritePrivateProfileStructW prevent null pointer dereference
From: Fabian Maurer dark.shadow4@web.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49285 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/kernel32/profile.c | 5 +++++ dlls/kernel32/tests/profile.c | 4 ++++ 2 files changed, 9 insertions(+)
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index e70874fa36f..bf1a9170896 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -2044,9 +2044,14 @@ BOOL WINAPI WritePrivateProfileStructW (LPCWSTR section, LPCWSTR key, LPWSTR outstring, p; DWORD sum = 0;
+ TRACE("(%s %s %p %u %s)\n", debugstr_w(section), debugstr_w(key), buf, bufsize, debugstr_w(filename)); + if (!section && !key && !buf) /* flush the cache */ return WritePrivateProfileStringW( NULL, NULL, NULL, filename );
+ if (!buf) + return WritePrivateProfileStringW(section, key, NULL, filename); + /* allocate string buffer for hex chars + checksum hex char + '\0' */ outstring = HeapAlloc( GetProcessHeap(), 0, (bufsize*2 + 2 + 1) * sizeof(WCHAR) ); p = outstring; diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c index 71d945f81df..dc5beb89823 100644 --- a/dlls/kernel32/tests/profile.c +++ b/dlls/kernel32/tests/profile.c @@ -1173,6 +1173,10 @@ static void test_profile_struct(void) ok(!ret, "expected failure\n"); todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %lu\n", GetLastError());
+ /* Test deleting struct */ + ret = WritePrivateProfileStructA("s", "key", NULL, sizeof("abacus"), "./winetest.ini"); /* Must not crash */ + ok(ret, "got error %lu\n", GetLastError()); + ret = DeleteFileA("./winetest.ini"); ok(ret, "got error %lu\n", GetLastError()); }
On 5/16/22 12:31, Fabian Maurer wrote:
From: Fabian Maurer dark.shadow4@web.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49285 Signed-off-by: Fabian Maurer dark.shadow4@web.de
dlls/kernel32/profile.c | 5 +++++ dlls/kernel32/tests/profile.c | 4 ++++ 2 files changed, 9 insertions(+)
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index e70874fa36f..bf1a9170896 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -2044,9 +2044,14 @@ BOOL WINAPI WritePrivateProfileStructW (LPCWSTR section, LPCWSTR key, LPWSTR outstring, p; DWORD sum = 0;
TRACE("(%s %s %p %u %s)\n", debugstr_w(section), debugstr_w(key), buf, bufsize, debugstr_w(filename));
if (!section && !key && !buf) /* flush the cache */ return WritePrivateProfileStringW( NULL, NULL, NULL, filename );
if (!buf)
return WritePrivateProfileStringW(section, key, NULL, filename);
/* allocate string buffer for hex chars + checksum hex char + '\0' */ outstring = HeapAlloc( GetProcessHeap(), 0, (bufsize*2 + 2 + 1) * sizeof(WCHAR) ); p = outstring;
diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c index 71d945f81df..dc5beb89823 100644 --- a/dlls/kernel32/tests/profile.c +++ b/dlls/kernel32/tests/profile.c @@ -1173,6 +1173,10 @@ static void test_profile_struct(void) ok(!ret, "expected failure\n"); todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %lu\n", GetLastError());
- /* Test deleting struct */
- ret = WritePrivateProfileStructA("s", "key", NULL, sizeof("abacus"), "./winetest.ini"); /* Must not crash */
- ok(ret, "got error %lu\n", GetLastError());
Can you please test that this actually does delete the field?
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=114807
Your paranoid android.
=== debian11 (32 bit WoW report) ===
kernel32: change.c:339: Test failed: should be ready