From 228593f9068f745193afefa6a1f0184b5d210880 Mon Sep 17 00:00:00 2001 From: Heyi Guo Date: Mon, 6 Jul 2015 06:34:47 +0000 Subject: [PATCH] MdePkg: Fix bug in CatVSPrint introduced by r17742. Just use a more conservative way to replace unsafe StrCpy. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Heyi Guo Reviewed-by: Liming Gao Reviewed-by: Qiu Shumin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17823 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Library/UefiLib/UefiLibPrint.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/UefiLib/UefiLibPrint.c b/MdePkg/Library/UefiLib/UefiLibPrint.c index cc41eb0343..91ce49235b 100644 --- a/MdePkg/Library/UefiLib/UefiLibPrint.c +++ b/MdePkg/Library/UefiLib/UefiLibPrint.c @@ -754,11 +754,15 @@ CatVSPrint ( SizeRequired = sizeof(CHAR16) + (CharactersRequired * sizeof(CHAR16)); } - BufferToReturn = AllocateCopyPool(SizeRequired, String); + BufferToReturn = AllocateZeroPool(SizeRequired); if (BufferToReturn == NULL) { return NULL; } + + if (String != NULL) { + StrCpyS(BufferToReturn, SizeRequired, String); + } UnicodeVSPrint(BufferToReturn + StrLen(BufferToReturn), (CharactersRequired+1) * sizeof(CHAR16), FormatString, Marker);