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.
This commit is contained in:
Rob Shearman 2007-01-04 16:55:58 +00:00 committed by Alexandre Julliard
parent 2db1d0de38
commit 5398e17d0a
2 changed files with 8 additions and 5 deletions

View File

@ -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;

View File

@ -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);