Commit dcd195e0 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Add parameter checking in RtlNormalizeString().

parent 77f58afd
......@@ -6184,12 +6184,14 @@ static void test_NormalizeString(void)
case NormalizationKC:
case NormalizationKD:
case 13: /* Idn */
todo_wine_if (i == 13)
ok( dstlen > 0, "%d: wrong len %d\n", i, dstlen );
todo_wine ok( GetLastError() == ERROR_SUCCESS, "%d: got error %u\n", i, GetLastError());
break;
default:
todo_wine ok( dstlen <= 0, "%d: wrong len %d\n", i, dstlen );
todo_wine ok( GetLastError() == ERROR_INVALID_PARAMETER, "%d: got error %u\n", i, GetLastError());
ok( dstlen <= 0, "%d: wrong len %d\n", i, dstlen );
todo_wine_if (i)
ok( GetLastError() == ERROR_INVALID_PARAMETER, "%d: got error %u\n", i, GetLastError());
break;
}
if (pRtlNormalizeString)
......@@ -6199,17 +6201,18 @@ static void test_NormalizeString(void)
switch (i)
{
case 0:
todo_wine ok( status == STATUS_INVALID_PARAMETER, "%d: failed %x\n", i, status );
ok( status == STATUS_INVALID_PARAMETER, "%d: failed %x\n", i, status );
break;
case NormalizationC:
case NormalizationD:
case NormalizationKC:
case NormalizationKD:
case 13: /* Idn */
todo_wine_if (i == 13)
ok( status == STATUS_SUCCESS, "%d: failed %x\n", i, status );
break;
default:
todo_wine ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "%d: failed %x\n", i, status );
ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "%d: failed %x\n", i, status );
break;
}
}
......
......@@ -1687,17 +1687,26 @@ NTSTATUS WINAPI RtlIsNormalizedString( ULONG form, const WCHAR *str, INT len, BO
*/
NTSTATUS WINAPI RtlNormalizeString( ULONG form, const WCHAR *src, INT src_len, WCHAR *dst, INT *dst_len )
{
int flags = 0, compose = 0;
int flags = 0, compose, compat;
unsigned int res, buf_len;
WCHAR *buf = NULL;
NTSTATUS status = STATUS_SUCCESS;
TRACE( "%x %s %d %p %d\n", form, debugstr_wn(src, src_len), src_len, dst, *dst_len );
switch (form)
{
case NormalizationC: compose = 1; compat = 0; break;
case NormalizationD: compose = 0; compat = 0; break;
case NormalizationKC: compose = 1; compat = 1; break;
case NormalizationKD: compose = 0; compat = 1; break;
case 0: return STATUS_INVALID_PARAMETER;
default: return STATUS_OBJECT_NAME_NOT_FOUND;
}
if (src_len == -1) src_len = strlenW(src) + 1;
if (form == NormalizationKC || form == NormalizationKD) flags |= WINE_DECOMPOSE_COMPAT;
if (form == NormalizationC || form == NormalizationKC) compose = 1;
if (compat) flags |= WINE_DECOMPOSE_COMPAT;
if (compose || *dst_len) flags |= WINE_DECOMPOSE_REORDER;
if (!compose && *dst_len)
......
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