Skip to content
Snippets Groups Projects
Commit 8baf70a2 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard
Browse files

user32: Fix wsprintfA's buffer usage when using %S.


This fixes a regression introduced by
08bf605a.
It could lead to stack corruption because ret can be negative when the
output position, p, doesn't point the beginning of the buffer before
the inner loop.

Signed-off-by: default avatarAkihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Alexandre Julliard's avatarAlexandre Julliard <julliard@winehq.org>
parent 31800a14
No related branches found
No related tags found
No related merge requests found
......@@ -413,8 +413,8 @@ static INT wvsnprintfA( LPSTR buffer, UINT maxlen, LPCSTR spec, __ms_va_list arg
{
CHAR mb[5]; /* 5 is MB_LEN_MAX */
int ret = WideCharToMultiByte( CP_ACP, 0, ptr, 1, mb, sizeof(mb), NULL, NULL );
if (ret > len - i) ret = len - i;
i += ret;
if (i > len) ret = len - (p - buffer);
memcpy( p, mb, ret );
p += ret;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment