]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiLib/UefiLibPrint.c
MdePkg UefiLib: Fix wrong DestMax passed to StrCpyS()
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiLibPrint.c
index 1bf6d26821e32bf5ab67e9e6ed1ba93d5c0c375b..9f52e7d0ceb8193c7403f572a7090869a53b3d66 100644 (file)
@@ -2,7 +2,7 @@
   Mde UEFI library API implementation.\r
   Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE\r
 \r
-  Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -754,14 +754,16 @@ CatVSPrint (
     SizeRequired = sizeof(CHAR16) + (CharactersRequired * sizeof(CHAR16));\r
   }\r
 \r
-  BufferToReturn = AllocateZeroPool(SizeRequired);\r
+  BufferToReturn = AllocatePool(SizeRequired);\r
 \r
   if (BufferToReturn == NULL) {\r
     return NULL;\r
+  } else {\r
+    BufferToReturn[0] = L'\0';\r
   }\r
 \r
   if (String != NULL) {\r
-    StrCpy(BufferToReturn, String);\r
+    StrCpyS(BufferToReturn, SizeRequired / sizeof(CHAR16), String);\r
   }\r
 \r
   UnicodeVSPrint(BufferToReturn + StrLen(BufferToReturn), (CharactersRequired+1) * sizeof(CHAR16), FormatString, Marker);\r