SVN r17742 uses AllocateCopyPool to replace AllocateZeroPool, however
String can be NULL and this will trigger assert in AllocateCopyPool.
Error Can be replayed when we use "cd <dir>" command under Shell.

Just use a more conservative way to replace unsafe StrCpy.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi....@linaro.org>
---
 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 cc41eb0..604c25b 100644
--- a/MdePkg/Library/UefiLib/UefiLibPrint.c
+++ b/MdePkg/Library/UefiLib/UefiLibPrint.c
@@ -754,12 +754,16 @@ 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);
 
   ASSERT(StrSize(BufferToReturn)==SizeRequired);
-- 
2.1.4


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to