msvcrt: Use memmove to copy memory in wmemcpy_s.
Fixes memory corruption in Outlook 2016. Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
099a12ad40
commit
be56a83fd0
|
@ -371,7 +371,7 @@ static BOOL init(void)
|
||||||
|
|
||||||
static void test_wmemcpy_s(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 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};
|
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 */
|
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);
|
okwchars(dest, XX, XX, XX, XX, XX, XX, XX, XX);
|
||||||
CHECK_CALLED(invalid_parameter_handler);
|
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,
|
ok(p_set_invalid_parameter_handler(NULL) == test_invalid_parameter_handler,
|
||||||
"Cannot reset invalid parameter handler\n");
|
"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;
|
return MSVCRT_ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(dest, src, sizeof(MSVCRT_wchar_t)*count);
|
memmove(dest, src, sizeof(MSVCRT_wchar_t)*count);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue