Akihiro Sagawa : quartz: Ensure error text is terminated with NUL character.
Module: wine Branch: master Commit: fc4ef8692e82b3e480b76daf088f099897a790e8 URL: https://source.winehq.org/git/wine.git/?a=commit;h=fc4ef8692e82b3e480b76daf0... Author: Akihiro Sagawa <sagawa.aki(a)gmail.com> Date: Thu May 30 22:58:09 2019 +0900 quartz: Ensure error text is terminated with NUL character. Signed-off-by: Akihiro Sagawa <sagawa.aki(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/quartz/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/quartz/main.c b/dlls/quartz/main.c index 08287a7..282104e 100644 --- a/dlls/quartz/main.c +++ b/dlls/quartz/main.c @@ -313,7 +313,13 @@ DWORD WINAPI AMGetErrorTextA(HRESULT hr, LPSTR buffer, DWORD maxlen) return 0; res = AMGetErrorTextW(hr, errorW, ARRAY_SIZE(errorW)); - return WideCharToMultiByte(CP_ACP, 0, errorW, res, buffer, maxlen, 0, 0); + if (!res) + return 0; + + res = WideCharToMultiByte(CP_ACP, 0, errorW, -1, NULL, 0, 0, 0); + if (res > maxlen || !res) + return 0; + return WideCharToMultiByte(CP_ACP, 0, errorW, -1, buffer, maxlen, 0, 0) - 1; } /***********************************************************************
participants (1)
-
Alexandre Julliard