MdeModulePkg/Application/MemoryProfileInfo: Use safe string functions to refine code.
authorQiu Shumin <shumin.qiu@intel.com>
Wed, 1 Jul 2015 08:03:50 +0000 (08:03 +0000)
committershenshushi <shenshushi@Edk2>
Wed, 1 Jul 2015 08:03:50 +0000 (08:03 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17777 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c

index 6304b7fc6c160edf3a8dcf08fd45511f620c75f7..b425af17c20720a7d0c08a652efc6e0d32429839 100644 (file)
@@ -121,10 +121,10 @@ GetShortPdbFileName (
   UINTN StartIndex;\r
   UINTN EndIndex;\r
 \r
-  ZeroMem (UnicodeBuffer, PROFILE_NAME_STRING_LENGTH * sizeof (CHAR16));\r
+  ZeroMem (UnicodeBuffer, (PROFILE_NAME_STRING_LENGTH + 1) * sizeof (CHAR16));\r
 \r
   if (PdbFileName == NULL) {\r
-    StrnCpy (UnicodeBuffer, L" ", 1);\r
+    StrnCpyS (UnicodeBuffer, PROFILE_NAME_STRING_LENGTH + 1, L" ", 1);\r
   } else {\r
     StartIndex = 0;\r
     for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++);\r
@@ -201,7 +201,7 @@ GetDriverNameString (
       //\r
       // Method 2: Get the name string from FFS UI section\r
       //\r
-      StrnCpy (mNameString, NameString, PROFILE_NAME_STRING_LENGTH);\r
+      StrCpyS (mNameString, PROFILE_NAME_STRING_LENGTH + 1, NameString);\r
       mNameString[PROFILE_NAME_STRING_LENGTH] = 0;\r
       FreePool (NameString);\r
       return;\r