Commit 5398e17d authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

ntdll: RtlInitUnicodeString on a string too long to fit in a UNICODE_STRING

should set the it to have the maximum possible length and size rather than a modulus of the actual length. Fix test failures for RtlInitUnicodeString on Windows XP upwards.
parent 2db1d0de
......@@ -215,7 +215,10 @@ void WINAPI RtlInitUnicodeString(
{
if ((target->Buffer = (PWSTR) source))
{
target->Length = strlenW(source) * sizeof(WCHAR);
unsigned int length = strlenW(source) * sizeof(WCHAR);
if (length > 0xfffc)
length = 0xfffc;
target->Length = length;
target->MaximumLength = target->Length + sizeof(WCHAR);
}
else target->Length = target->MaximumLength = 0;
......
......@@ -246,12 +246,12 @@ static void test_RtlInitUnicodeStringEx(void)
uni.MaximumLength = 12345;
uni.Buffer = (void *) 0xdeadbeef;
pRtlInitUnicodeString(&uni, teststring2);
ok(uni.Length == 33920,
ok(uni.Length == 33920 /* <= Win2000 */ || uni.Length == 65532 /* >= Win XP */,
"pRtlInitUnicodeString(&uni, 0) sets Length to %u, expected %u\n",
uni.Length, 33920);
ok(uni.MaximumLength == 33922,
uni.Length, 65532);
ok(uni.MaximumLength == 33922 /* <= Win2000 */ || uni.MaximumLength == 65534 /* >= Win XP */,
"pRtlInitUnicodeString(&uni, 0) sets MaximumLength to %u, expected %u\n",
uni.MaximumLength, 33922);
uni.MaximumLength, 65534);
ok(uni.Buffer == teststring2,
"pRtlInitUnicodeString(&uni, 0) sets Buffer to %p, expected %p\n",
uni.Buffer, teststring2);
......
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