Module: wine Branch: master Commit: 4aebd6a95fe8f274ad21963fd6ce682b2af3a61e URL: https://source.winehq.org/git/wine.git/?a=commit;h=4aebd6a95fe8f274ad21963fd...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Feb 28 15:34:52 2020 +0100
ntdll: Allow final null in RtlNormalizeString() even if 0 is an invalid character.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/kernel32/tests/locale.c | 1 - dlls/ntdll/locale.c | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index 7cc7f5d376..1df3c0dcd6 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -4521,7 +4521,6 @@ static void test_IdnToNameprepUnicode(void) int len = ARRAY_SIZE(buf); memset( buf, 0xcc, sizeof(buf) ); status = pRtlNormalizeString( 13, test_data[i].in, test_data[i].in_len, buf, &len ); - todo_wine_if (!test_data[i].status && (test_data[i].in_len == -1 || !test_data[i].in[test_data[i].in_len - 1])) ok( status == test_data[i].status || broken(status == test_data[i].broken_status), "%d: failed %x\n", i, status ); if (!status) ok( !wcsncmp(test_data[i].out, buf, len), "%d: buf = %s\n", i, wine_dbgstr_wn(buf, len)); diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c index 7ec8a16074..8a2b233f88 100644 --- a/dlls/ntdll/locale.c +++ b/dlls/ntdll/locale.c @@ -437,6 +437,12 @@ static NTSTATUS decompose_string( const struct norm_table *info, const WCHAR *sr props = get_char_props( info, ch ); if (!(decomp = get_decomposition( info, ch, props, buffer, &decomp_len ))) { + /* allow final null */ + if (!ch && src_pos == src_len - 1 && dst_pos < *dst_len) + { + dst[dst_pos++] = 0; + break; + } *dst_len = src_pos; return STATUS_NO_UNICODE_TRANSLATION; } @@ -1934,6 +1940,8 @@ NTSTATUS WINAPI RtlIsNormalizedString( ULONG form, const WCHAR *str, INT len, BO /* ignore other chars in Hangul range */ if (ch >= HANGUL_LBASE && ch < HANGUL_LBASE + 0x100) continue; if (ch >= HANGUL_SBASE && ch < HANGUL_SBASE + 0x2c00) continue; + /* allow final null */ + if (!ch && i == len - 1) continue; return STATUS_NO_UNICODE_TRANSLATION; } }