Commit be56a83f authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

msvcrt: Use memmove to copy memory in wmemcpy_s.

Fixes memory corruption in Outlook 2016. Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 099a12ad
......@@ -371,7 +371,7 @@ static BOOL init(void)
static void test_wmemcpy_s(void)
{
static wchar_t dest[8];
static wchar_t dest[8], buf[32];
static const wchar_t tiny[] = {'T',0,'I','N','Y',0};
static const wchar_t big[] = {'a','t','o','o','l','o','n','g','s','t','r','i','n','g',0};
const wchar_t XX = 0x5858; /* two 'X' bytes */
......@@ -434,6 +434,18 @@ static void test_wmemcpy_s(void)
okwchars(dest, XX, XX, XX, XX, XX, XX, XX, XX);
CHECK_CALLED(invalid_parameter_handler);
ret = p_wmemcpy_s(buf, ARRAY_SIZE(buf), big, ARRAY_SIZE(big));
ok(!ret, "wmemcpy_s returned %d\n", ret);
ok(!memcmp(buf, big, sizeof(big)), "unexpected buf\n");
ret = p_wmemcpy_s(buf + 1, ARRAY_SIZE(buf) - 1, buf, ARRAY_SIZE(big));
ok(!ret, "wmemcpy_s returned %d\n", ret);
ok(!memcmp(buf + 1, big, sizeof(big)), "unexpected buf\n");
ret = p_wmemcpy_s(buf, ARRAY_SIZE(buf), buf + 1, ARRAY_SIZE(big));
ok(!ret, "wmemcpy_s returned %d\n", ret);
ok(!memcmp(buf, big, sizeof(big)), "unexpected buf\n");
ok(p_set_invalid_parameter_handler(NULL) == test_invalid_parameter_handler,
"Cannot reset invalid parameter handler\n");
}
......
......@@ -826,7 +826,7 @@ int CDECL wmemcpy_s(MSVCRT_wchar_t *dest, MSVCRT_size_t numberOfElements,
return MSVCRT_ERANGE;
}
memcpy(dest, src, sizeof(MSVCRT_wchar_t)*count);
memmove(dest, src, sizeof(MSVCRT_wchar_t)*count);
return 0;
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment