]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/String.c
Fix a bug in MdePkg BaseLib: StrnCat() and AsciiStrnCat() should NULL terminated...
[mirror_edk2.git] / 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