]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix a bug in MdePkg BaseLib: StrnCat() and AsciiStrnCat() should NULL terminated...
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 23 Dec 2009 01:50:10 +0000 (01:50 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 23 Dec 2009 01:50:10 +0000 (01:50 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9588 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BaseLib/String.c

index 31ea36de414d36c4670b66403c20c6d135da1730..afbad1d4e3277a5290569f41a0fd2c1c68ce1dd3 100644 (file)
@@ -425,7 +425,11 @@ StrnCat (
   IN      UINTN                     Length\r
   )\r
 {\r
-  StrnCpy (Destination + StrLen (Destination), Source, Length);\r
+  UINTN   DestinationLen;\r
+\r
+  DestinationLen = StrLen (Destination);\r
+  StrnCpy (Destination + DestinationLen, Source, Length);\r
+  Destination[DestinationLen + Length] = L'\0';\r
 \r
   //\r
   // Size of the resulting string should never be zero.\r
@@ -1566,7 +1570,11 @@ AsciiStrnCat (
   IN      UINTN                     Length\r
   )\r
 {\r
-  AsciiStrnCpy (Destination + AsciiStrLen (Destination), Source, Length);\r
+  UINTN   DestinationLen;\r
+\r
+  DestinationLen = AsciiStrLen (Destination);\r
+  AsciiStrnCpy (Destination + DestinationLen, Source, Length);\r
+  Destination[DestinationLen + Length] = '\0';\r
 \r
   //\r
   // Size of the resulting string should never be zero.\r