Rob Shearman : ntdll:
RtlInitUnicodeString on a string too long to fit in a UNICODE_STRING
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jan 4 15:09:25 CST 2007
Module: wine
Branch: master
Commit: 5398e17d0ac88d3b300b6868c5d2a858c57d1095
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5398e17d0ac88d3b300b6868c5d2a858c57d1095
Author: Rob Shearman <rob at codeweavers.com>
Date: Thu Jan 4 16:55:58 2007 +0000
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.
---
dlls/ntdll/rtlstr.c | 5 ++++-
dlls/ntdll/tests/rtlstr.c | 8 ++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c
index 8e997e7..34336fd 100644
--- a/dlls/ntdll/rtlstr.c
+++ b/dlls/ntdll/rtlstr.c
@@ -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;
diff --git a/dlls/ntdll/tests/rtlstr.c b/dlls/ntdll/tests/rtlstr.c
index 52f0ee3..cc1606a 100644
--- a/dlls/ntdll/tests/rtlstr.c
+++ b/dlls/ntdll/tests/rtlstr.c
@@ -246,12 +246,12 @@ static void test_RtlInitUnicodeStringEx(
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);
More information about the wine-cvs
mailing list