kernel32: Fix LCMapString buffer calculation with LCMAP_KATAKANA and LCMAP_HALFWIDTH.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45982
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2018-10-16 00:31:23 +09:00 committed by Alexandre Julliard
parent 96b4a5a356
commit b02cdd3615
2 changed files with 9 additions and 2 deletions

View File

@ -3557,9 +3557,17 @@ INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPW
else if (flags & LCMAP_HALFWIDTH) else if (flags & LCMAP_HALFWIDTH)
{ {
for (len = 0; srclen; src++, srclen--, len++) for (len = 0; srclen; src++, srclen--, len++)
if (decompose_katakana(*src, NULL, 0) == 2) {
WCHAR wch = *src;
/* map Hiragana to Katakana before decomposition if needed */
if ((flags & LCMAP_KATAKANA) &&
((wch >= 0x3041 && wch <= 0x3096) || wch == 0x309D || wch == 0x309E))
wch += 0x60;
if (decompose_katakana(wch, NULL, 0) == 2)
len++; len++;
} }
}
else else
len = srclen; len = srclen;
return len; return len;

View File

@ -2537,7 +2537,6 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
ok(!lstrcmpW(buf, halfwidth_text2), "%s string compare mismatch\n", func_name); ok(!lstrcmpW(buf, halfwidth_text2), "%s string compare mismatch\n", func_name);
ret2 = func_ptr(LCMAP_HALFWIDTH | LCMAP_KATAKANA, japanese_text, -1, NULL, 0); ret2 = func_ptr(LCMAP_HALFWIDTH | LCMAP_KATAKANA, japanese_text, -1, NULL, 0);
todo_wine
ok(ret == ret2, "%s ret %d, expected value %d\n", func_name, ret, ret2); ok(ret == ret2, "%s ret %d, expected value %d\n", func_name, ret, ret2);
/* test buffer overflow */ /* test buffer overflow */