[PATCH v2 0/2] MR3755: win32u: Correct the packed size of WM_GETDLGCODE when lparam is NULL.
If lparam is null, the current code crashes when it hits the memcpy in pack_user_message. -- v2: win32u: Correct the packed size of WM_GETDLGCODE when lparam is NULL. win32u: Add a test for cross-process WM_GETDLGCODE with a NULL lparam. https://gitlab.winehq.org/wine/wine/-/merge_requests/3755
From: Tim Clem <tclem(a)codeweavers.com> Co-authored-by: Jacek Caban <jacek(a)codeweavers.com> --- dlls/win32u/tests/win32u.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index 25358c5d0d8..efc7249eca7 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -964,6 +964,9 @@ static LRESULT WINAPI test_ipc_message_proc( HWND hwnd, UINT msg, WPARAM wparam, ok( !wcscmp( mdi->szTitle, L"TestTitle" ), "szTitle = %s\n", wine_dbgstr_w( mdi->szTitle )); return 0xdeadbeef; } + + case WM_GETDLGCODE: + return !lparam; } return DefWindowProcW( hwnd, msg, wparam, lparam ); @@ -1059,6 +1062,10 @@ static void test_inter_process_child( HWND hwnd ) res = NtUserMessageCall( hwnd, WM_GETTEXTLENGTH, 0, 0, NULL, NtUserSendMessage, TRUE ); ok( res == 4, "res = %d\n", res ); + res = NtUserMessageCall( hwnd, WM_GETDLGCODE, 0, 0, NULL, NtUserSendMessage, TRUE ); + todo_wine + ok( res == 1, "res = %d\n", res ); + mdi.szClass = "TestClass"; mdi.szTitle = "TestTitle"; mdi.hOwner = 0; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3755
From: Tim Clem <tclem(a)codeweavers.com> --- dlls/win32u/message.c | 2 +- dlls/win32u/tests/win32u.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index d15f9af3f9f..d2909339983 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -1691,7 +1691,7 @@ size_t user_message_size( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, size = sizeof(STYLESTRUCT); break; case WM_GETDLGCODE: - size = sizeof(MSG); + if (lparam) size = sizeof(MSG); break; case SBM_SETSCROLLINFO: case SBM_GETSCROLLINFO: diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index efc7249eca7..e118d081ead 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -1063,7 +1063,6 @@ static void test_inter_process_child( HWND hwnd ) ok( res == 4, "res = %d\n", res ); res = NtUserMessageCall( hwnd, WM_GETDLGCODE, 0, 0, NULL, NtUserSendMessage, TRUE ); - todo_wine ok( res == 1, "res = %d\n", res ); mdi.szClass = "TestClass"; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3755
On Fri Sep 8 16:15:08 2023 +0000, Jacek Caban wrote:
The fix looks good, but it would be nice to have a test. Please include something like the [attached test](/uploads/4ff2f549a3d6edd1d7076f2968c584e2/patch.diff). Ah, thanks! I saw an existing test with a null lparam but didn't think to consider that it needed to be IPC to hit this code path. Added your test in v2.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/3755#note_44720
This merge request was approved by Jacek Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3755
participants (3)
-
Jacek Caban (@jacek) -
Tim Clem -
Tim Clem (@tclem)