diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-07-30 09:03:16 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-07-30 09:03:16 +0000 |
commit | 769d21528d9008c03bff22a3e3a63d7166277bf8 (patch) | |
tree | 45e4e06fbc8de17cf7246ec1b942a294b602c8c6 | |
parent | 50f0d9069dad80e59b09e69313b665545259dd55 (diff) | |
download | edk2-769d21528d9008c03bff22a3e3a63d7166277bf8.tar.gz |
Sync patch r9588 from main trunk.
r9588 - Fix a bug in MdePkg BaseLib: StrnCat() and AsciiStrnCat() should NULL terminated the final destination string
when Length is equal to the length of Source string.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2008@10755 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | MdePkg/Library/BaseLib/String.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c index 31ea36de41..afbad1d4e3 100644 --- a/MdePkg/Library/BaseLib/String.c +++ b/MdePkg/Library/BaseLib/String.c @@ -425,7 +425,11 @@ StrnCat ( IN UINTN Length
)
{
- StrnCpy (Destination + StrLen (Destination), Source, Length);
+ UINTN DestinationLen;
+
+ DestinationLen = StrLen (Destination);
+ StrnCpy (Destination + DestinationLen, Source, Length);
+ Destination[DestinationLen + Length] = L'\0';
//
// Size of the resulting string should never be zero.
@@ -1566,7 +1570,11 @@ AsciiStrnCat ( IN UINTN Length
)
{
- AsciiStrnCpy (Destination + AsciiStrLen (Destination), Source, Length);
+ UINTN DestinationLen;
+
+ DestinationLen = AsciiStrLen (Destination);
+ AsciiStrnCpy (Destination + DestinationLen, Source, Length);
+ Destination[DestinationLen + Length] = '\0';
//
// Size of the resulting string should never be zero.
|