]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFrameworkModulePkg BdsDxe: Fix ASSERT in BdsMemoryTest
authorHao Wu <hao.a.wu@intel.com>
Mon, 13 Jul 2015 01:22:44 +0000 (01:22 +0000)
committerhwu1225 <hwu1225@Edk2>
Mon, 13 Jul 2015 01:22:44 +0000 (01:22 +0000)
This commit will resolve the issue brought by r17735.

StrCatS (StrPercent, sizeof (StrPercent) / sizeof (CHAR16), TmpStr);

The above using of StrCatS will cause ASSERT if TmpStr is longer than
StrPercent. Therefore, StrnCatS is used here to resolve the issue.

Similar scenario is for:
StrCatS (StrTotalMemory, StrTotalMemorySize / sizeof (CHAR16), TmpStr);

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17930 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c

index eef840b8826f86067ac2fbc86f980d00786811ff..fedb151a0c63bb3195a70af2e81d6fb7c0ccb3f9 100644 (file)
@@ -324,7 +324,12 @@ BdsMemoryTest (
           //\r
           // TmpStr size is 64, StrPercent is reserved to 16.\r
           //\r
-          StrCatS (StrPercent, sizeof (StrPercent) / sizeof (CHAR16), TmpStr);\r
+          StrnCatS (\r
+            StrPercent,\r
+            sizeof (StrPercent) / sizeof (CHAR16), \r
+            TmpStr,\r
+            sizeof (StrPercent) / sizeof (CHAR16) - StrLen (StrPercent) - 1\r
+            );\r
           PrintXY (10, 10, NULL, NULL, StrPercent);\r
           FreePool (TmpStr);\r
         }\r
@@ -389,7 +394,12 @@ Done:
 \r
     TmpStr = GetStringById (STRING_TOKEN (STR_MEM_TEST_COMPLETED));\r
     if (TmpStr != NULL) {\r
-      StrCatS (StrTotalMemory, StrTotalMemorySize / sizeof (CHAR16), TmpStr);\r
+      StrnCatS (\r
+        StrTotalMemory,\r
+        StrTotalMemorySize / sizeof (CHAR16),\r
+        TmpStr,\r
+        StrTotalMemorySize / sizeof (CHAR16) - StrLen (StrTotalMemory) - 1\r
+        );\r
       FreePool (TmpStr);\r
     }\r
 \r