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. Modified: trunk/reactos/lib/rtl/unicode.c _____
Modified: trunk/reactos/lib/rtl/unicode.c --- trunk/reactos/lib/rtl/unicode.c 2005-01-13 20:30:59 UTC (rev 13029) +++ trunk/reactos/lib/rtl/unicode.c 2005-01-13 20:53:35 UTC (rev 13030) @@ -2195,11 +2195,14 @@
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 @@ 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; }