mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
Don't add a terminating null character in RtlCopyString, if the destination buffer isn't large enough.
A ansi/unicode string doesn't need a terminating null character. svn path=/trunk/; revision=13030
This commit is contained in:
parent
1a99f299a1
commit
7e23b350aa
1 changed files with 10 additions and 4 deletions
|
@ -2195,11 +2195,14 @@ RtlCopyString(
|
|||
return;
|
||||
}
|
||||
|
||||
copylen = min (DestinationString->MaximumLength - sizeof(CHAR),
|
||||
copylen = min (DestinationString->MaximumLength,
|
||||
SourceString->Length);
|
||||
|
||||
memcpy(DestinationString->Buffer, SourceString->Buffer, copylen);
|
||||
DestinationString->Buffer[copylen] = 0;
|
||||
if (DestinationString->MaximumLength >= copylen + sizeof(CHAR))
|
||||
{
|
||||
DestinationString->Buffer[copylen] = 0;
|
||||
}
|
||||
DestinationString->Length = copylen;
|
||||
}
|
||||
|
||||
|
@ -2222,10 +2225,13 @@ RtlCopyUnicodeString(
|
|||
return;
|
||||
}
|
||||
|
||||
copylen = min (DestinationString->MaximumLength - sizeof(WCHAR),
|
||||
copylen = min (DestinationString->MaximumLength,
|
||||
SourceString->Length);
|
||||
memcpy(DestinationString->Buffer, SourceString->Buffer, copylen);
|
||||
DestinationString->Buffer[copylen / sizeof(WCHAR)] = 0;
|
||||
if (DestinationString->MaximumLength >= copylen + sizeof(WCHAR))
|
||||
{
|
||||
DestinationString->Buffer[copylen / sizeof(WCHAR)] = 0;
|
||||
}
|
||||
DestinationString->Length = copylen;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue