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:
Hartmut Birr 2005-01-13 20:53:35 +00:00
parent 1a99f299a1
commit 7e23b350aa

View file

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