mirror of
https://github.com/reactos/reactos.git
synced 2024-07-22 20:28:08 +00:00
[RTL] - Make sure RtlInitUnicodeString(Ex) don't set odd length. Fixes ntdll:rtlstr winetest.
svn path=/trunk/; revision=54061
This commit is contained in:
parent
34c8ab588c
commit
975d94d909
|
@ -584,11 +584,12 @@ RtlInitUnicodeString(
|
|||
IN PCWSTR SourceString)
|
||||
{
|
||||
SIZE_T Size;
|
||||
CONST SIZE_T MaxSize = (MAXUSHORT & ~1) - sizeof(WCHAR); // an even number
|
||||
|
||||
if (SourceString)
|
||||
{
|
||||
Size = wcslen(SourceString) * sizeof(WCHAR);
|
||||
if (Size > (MAXUSHORT - sizeof(WCHAR))) Size = MAXUSHORT - sizeof(WCHAR);
|
||||
if (Size > MaxSize) Size = MaxSize;
|
||||
DestinationString->Length = (USHORT)Size;
|
||||
DestinationString->MaximumLength = (USHORT)Size + sizeof(WCHAR);
|
||||
}
|
||||
|
@ -611,11 +612,12 @@ RtlInitUnicodeStringEx(
|
|||
IN PCWSTR SourceString)
|
||||
{
|
||||
SIZE_T Size;
|
||||
CONST SIZE_T MaxSize = (MAXUSHORT & ~1) - sizeof(WCHAR); // an even number
|
||||
|
||||
if (SourceString)
|
||||
{
|
||||
Size = wcslen(SourceString) * sizeof(WCHAR);
|
||||
if (Size > (MAXUSHORT - sizeof(WCHAR))) return STATUS_NAME_TOO_LONG;
|
||||
if (Size > MaxSize) return STATUS_NAME_TOO_LONG;
|
||||
DestinationString->Length = (USHORT)Size;
|
||||
DestinationString->MaximumLength = (USHORT)Size + sizeof(WCHAR);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue