kernel32: Check the size of the string in CompareStringA.
This commit is contained in:
parent
28951a0922
commit
aaed0e81d5
|
@ -2979,7 +2979,7 @@ INT WINAPI CompareStringA(LCID lcid, DWORD flags,
|
||||||
WCHAR *buf1W = NtCurrentTeb()->StaticUnicodeBuffer;
|
WCHAR *buf1W = NtCurrentTeb()->StaticUnicodeBuffer;
|
||||||
WCHAR *buf2W = buf1W + 130;
|
WCHAR *buf2W = buf1W + 130;
|
||||||
LPWSTR str1W, str2W;
|
LPWSTR str1W, str2W;
|
||||||
INT len1W, len2W, ret;
|
INT len1W = 0, len2W = 0, ret;
|
||||||
UINT locale_cp = CP_ACP;
|
UINT locale_cp = CP_ACP;
|
||||||
|
|
||||||
if (!str1 || !str2)
|
if (!str1 || !str2)
|
||||||
|
@ -2994,7 +2994,7 @@ INT WINAPI CompareStringA(LCID lcid, DWORD flags,
|
||||||
|
|
||||||
if (len1)
|
if (len1)
|
||||||
{
|
{
|
||||||
len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, buf1W, 130);
|
if (len1 <= 130) len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, buf1W, 130);
|
||||||
if (len1W)
|
if (len1W)
|
||||||
str1W = buf1W;
|
str1W = buf1W;
|
||||||
else
|
else
|
||||||
|
@ -3017,7 +3017,7 @@ INT WINAPI CompareStringA(LCID lcid, DWORD flags,
|
||||||
|
|
||||||
if (len2)
|
if (len2)
|
||||||
{
|
{
|
||||||
len2W = MultiByteToWideChar(locale_cp, 0, str2, len2, buf2W, 130);
|
if (len2 <= 130) len2W = MultiByteToWideChar(locale_cp, 0, str2, len2, buf2W, 130);
|
||||||
if (len2W)
|
if (len2W)
|
||||||
str2W = buf2W;
|
str2W = buf2W;
|
||||||
else
|
else
|
||||||
|
|
|
@ -1466,7 +1466,6 @@ static void test_CompareStringA(void)
|
||||||
memset(a, 'a', sizeof(a));
|
memset(a, 'a', sizeof(a));
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = CompareStringA(lcid, 0, a, sizeof(a), a, sizeof(a));
|
ret = CompareStringA(lcid, 0, a, sizeof(a), a, sizeof(a));
|
||||||
todo_wine
|
|
||||||
ok (GetLastError() == 0xdeadbeef && ret == CSTR_EQUAL,
|
ok (GetLastError() == 0xdeadbeef && ret == CSTR_EQUAL,
|
||||||
"ret %d, error %d, expected value %d\n", ret, GetLastError(), CSTR_EQUAL);
|
"ret %d, error %d, expected value %d\n", ret, GetLastError(), CSTR_EQUAL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue