Revision: 17930
          http://sourceforge.net/p/edk2/code/17930
Author:   hwu1225
Date:     2015-07-13 01:22:44 +0000 (Mon, 13 Jul 2015)
Log Message:
-----------
IntelFrameworkModulePkg BdsDxe: Fix ASSERT in BdsMemoryTest

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 <[email protected]>
Reviewed-by: Qiu Shumin <[email protected]>
Reviewed-by: Jeff Fan <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/17735

Modified Paths:
--------------
    trunk/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c

Modified: trunk/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c
===================================================================
--- trunk/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c    
2015-07-13 01:22:21 UTC (rev 17929)
+++ trunk/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c    
2015-07-13 01:22:44 UTC (rev 17930)
@@ -324,7 +324,12 @@
           //
           // TmpStr size is 64, StrPercent is reserved to 16.
           //
-          StrCatS (StrPercent, sizeof (StrPercent) / sizeof (CHAR16), TmpStr);
+          StrnCatS (
+            StrPercent,
+            sizeof (StrPercent) / sizeof (CHAR16), 
+            TmpStr,
+            sizeof (StrPercent) / sizeof (CHAR16) - StrLen (StrPercent) - 1
+            );
           PrintXY (10, 10, NULL, NULL, StrPercent);
           FreePool (TmpStr);
         }
@@ -389,7 +394,12 @@
 
     TmpStr = GetStringById (STRING_TOKEN (STR_MEM_TEST_COMPLETED));
     if (TmpStr != NULL) {
-      StrCatS (StrTotalMemory, StrTotalMemorySize / sizeof (CHAR16), TmpStr);
+      StrnCatS (
+        StrTotalMemory,
+        StrTotalMemorySize / sizeof (CHAR16),
+        TmpStr,
+        StrTotalMemorySize / sizeof (CHAR16) - StrLen (StrTotalMemory) - 1
+        );
       FreePool (TmpStr);
     }
 


------------------------------------------------------------------------------
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-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to