[PATCH 0/1] MR8342: user32/tests: Make sure testtext has enough null bytes at the end.
testtext might be passed to DefWindowProcW in test_aw_conversion_dlgprocA, so it must have a WCHAR null at the end. * * * @nsivov it's also potentially possible for a WCHAR string to go throught W->A conversion then be passed to DefWindowProcW. in that case i am not sure how to guarantee it is wide-null terminated. this doesn't current happen in our test cases though. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8342
From: Yuxuan Shui <yshui(a)codeweavers.com> testtext might be passed to DefWindowProcW in test_aw_conversion_dlgprocA, so it must have a WCHAR null at the end. --- dlls/user32/tests/dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index 7ea0d13c0f3..d77af346c68 100644 --- a/dlls/user32/tests/dialog.c +++ b/dlls/user32/tests/dialog.c @@ -1456,7 +1456,7 @@ static INT_PTR CALLBACK TestControlStyleDlgProc(HWND hdlg, UINT msg, } static const WCHAR testtextW[] = {'W','n','d','T','e','x','t',0}; -static const char *testtext = "WndText"; +static const char *testtext = "WndText\0\0"; enum defdlgproc_text { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8342
Nikolay Sivov (@nsivov) commented about dlls/user32/tests/dialog.c:
}
static const WCHAR testtextW[] = {'W','n','d','T','e','x','t',0}; -static const char *testtext = "WndText"; +static const char *testtext = "WndText\0\0";
I can only look at this as a way to silence the failure. Could you explain where it fails in code exactly? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8342#note_106868
On Tue Jun 17 16:51:10 2025 +0000, Nikolay Sivov wrote:
I can only look at this as a way to silence the failure. Could you explain where it fails in code exactly? In `test_aw_conversion_dlgproc` we set DLGPROC to `test_aw_conversion_dlgprocA`, then we set "test_mode" to `DLGPROCTEXT_DLGPROCA`, and call `DefDlgProcA(hdlg, WM_SETTEXT, 0, (LPARAM)testtext)`.
So `testtext` gets passed as-is to `test_aw_conversion_dlgprocA`, which then passes it directly to `DefWindowProcW`. Since `DefWindowProcW` wants a wide string, it goes out-of-bound trying to `lstrlenW` it. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8342#note_106873
On Tue Jun 17 17:26:41 2025 +0000, Yuxuan Shui wrote:
In `test_aw_conversion_dlgproc` we set DLGPROC to `test_aw_conversion_dlgprocA`, then we set "test_mode" to `DLGPROCTEXT_DLGPROCA`, and call `DefDlgProcA(hdlg, WM_SETTEXT, 0, (LPARAM)testtext)`. So `testtext` gets passed as-is to `test_aw_conversion_dlgprocA`, which then passes it directly to `DefWindowProcW`. Since `DefWindowProcW` wants a wide string, it goes out-of-bound trying to `lstrlenW` it. I see, in this case it's enough to use "WndText\0". Also please add a code comment why this constant has to be that way, simply stating that it's passed to the ProcW function.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/8342#note_106896
participants (3)
-
Nikolay Sivov (@nsivov) -
Yuxuan Shui -
Yuxuan Shui (@yshui)