]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg UefiLib: Fix wrong DestMax passed to StrCpyS()
authorHao Wu <hao.a.wu@intel.com>
Wed, 5 Aug 2015 02:55:40 +0000 (02:55 +0000)
committerhwu1225 <hwu1225@Edk2>
Wed, 5 Aug 2015 02:55:40 +0000 (02:55 +0000)
The second parameter 'DestMax' of StrCpyS() should be the number of
unicode characters, not the size in bytes.

Also, code is modified to keep align with the one in
IntelFrameworkPkg\Library\FrameworkUefiLib\UefiLibPrint.c.

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>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18160 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/UefiLib/UefiLibPrint.c

index 91ce49235b62f30a1819b05a4e0279ace1099ecd..9f52e7d0ceb8193c7403f572a7090869a53b3d66 100644 (file)
@@ -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
+\r
   if (String != NULL) {\r
-    StrCpyS(BufferToReturn, SizeRequired, String);\r
+    StrCpyS(BufferToReturn, SizeRequired / sizeof(CHAR16), String);\r
   }\r
 \r
   UnicodeVSPrint(BufferToReturn + StrLen(BufferToReturn), (CharactersRequired+1) * sizeof(CHAR16), FormatString, Marker);\r