]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg UefiLib: Use safe string functions
authorHao Wu <hao.a.wu@intel.com>
Tue, 30 Jun 2015 06:29:51 +0000 (06:29 +0000)
committerhwu1225 <hwu1225@Edk2>
Tue, 30 Jun 2015 06:29:51 +0000 (06:29 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17742 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/UefiLib/Console.c
MdePkg/Library/UefiLib/UefiLibPrint.c

index 73f991532795bd899ff3bf635d3e1c022dcbf91f..ecaf425a0e937e08c8b16a3fbf185d7e654ec299 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This module provide help function for displaying unicode string.\r
 \r
-  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 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
@@ -517,8 +517,8 @@ CreatePopUp (
       UefiLibGetStringWidth (String, TRUE, MaxLength, &Length);\r
       TmpString = AllocateZeroPool ((Length + 1) * sizeof (CHAR16));\r
       ASSERT (TmpString != NULL);\r
-      StrnCpy(TmpString, String, Length - 3);\r
-      StrCat (TmpString, L"...");\r
+      StrnCpyS (TmpString, Length + 1, String, Length - 3);\r
+      StrCatS (TmpString, Length + 1, L"...");\r
 \r
       ConOut->SetCursorPosition (ConOut, Column + 1, Row++);\r
       ConOut->OutputString (ConOut, TmpString);\r
index 1bf6d26821e32bf5ab67e9e6ed1ba93d5c0c375b..cc41eb03433939bdc6469afa6c7745121bc7a286 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,16 +754,12 @@ CatVSPrint (
     SizeRequired = sizeof(CHAR16) + (CharactersRequired * sizeof(CHAR16));\r
   }\r
 \r
-  BufferToReturn = AllocateZeroPool(SizeRequired);\r
+  BufferToReturn = AllocateCopyPool(SizeRequired, String);\r
 \r
   if (BufferToReturn == NULL) {\r
     return NULL;\r
   }\r
 \r
-  if (String != NULL) {\r
-    StrCpy(BufferToReturn, String);\r
-  }\r
-\r
   UnicodeVSPrint(BufferToReturn + StrLen(BufferToReturn), (CharactersRequired+1) * sizeof(CHAR16), FormatString, Marker);\r
 \r
   ASSERT(StrSize(BufferToReturn)==SizeRequired);\r