[PATCH 0/1] MR8420: dsound: Make sure to null-terminate strings for callbacks.
WideCharToMultiByte normally null-terminates the output if input length is -1, but it doesn't do so if the output buffer is too small. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8420
From: Yuxuan Shui <yshui(a)codeweavers.com> WideCharToMultiByte normally null-terminates the output if input length is -1, but it doesn't do so if the output buffer is too small. --- dlls/dsound/dsound_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index bb373a4304d..b0874e3e675 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -299,7 +299,9 @@ static BOOL CALLBACK a_to_w_callback(LPGUID guid, LPCWSTR descW, LPCWSTR modW, L char descA[MAXPNAMELEN], modA[MAXPNAMELEN]; WideCharToMultiByte(CP_ACP, 0, descW, -1, descA, sizeof(descA), NULL, NULL); + descA[sizeof(descA)-1] = 0; WideCharToMultiByte(CP_ACP, 0, modW, -1, modA, sizeof(modA), NULL, NULL); + modA[sizeof(modA)-1] = 0; return context->callA(guid, descA, modA, context->data); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8420
I don't think we limit them in W functions, when mmdevapi friendly names are used, so this probably should be dynamically allocated? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8420#note_107817
participants (3)
-
Nikolay Sivov (@nsivov) -
Yuxuan Shui -
Yuxuan Shui (@yshui)