]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UnitTestFrameworkPkg/UnitTestResultReportLib: Use AsciiStrnCpyS()
authorMichael Kubacki <michael.kubacki@microsoft.com>
Thu, 21 May 2020 01:28:40 +0000 (09:28 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 27 May 2020 02:28:22 +0000 (02:28 +0000)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2721

The ReportOutput() function in UnitTestResultReportLib copies characters
from a function input buffer to an intermediate local buffer in fixed
size chunks of the maximum size of the intermediate buffer. The
implementation currently calls AsciiStrCpyS() which will ASSERT on an
error.

This commit changes the call to AsciiStrnCpyS() to avoid the
ASSERT which is not expected in the usage of the string copy in this
implementation.

Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c
UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c

index 139360ee1657c7aa28a151befd900df5af5ab1c3..cfb0c5972bd16b206954b228911fa1a2f52d50ff 100644 (file)
@@ -42,7 +42,7 @@ ReportOutput (
 \r
   Length = AsciiStrLen (Output);\r
   for (Index = 0; Index < Length; Index += (sizeof (AsciiString) - 1)) {\r
-    AsciiStrCpyS (AsciiString, sizeof (AsciiString), &Output[Index]);\r
+    AsciiStrnCpyS (AsciiString, sizeof (AsciiString), &Output[Index], sizeof (AsciiString) - 1);\r
     ReportPrint ("%a", AsciiString);\r
   }\r
 }\r
index 743aad2958a7485eefa4b90b5b9c6eeb20038461..1402d0ef83e2262eda1e02ca1b25d22bce9663d7 100644 (file)
@@ -41,7 +41,7 @@ ReportOutput (
 \r
   Length = AsciiStrLen (Output);\r
   for (Index = 0; Index < Length; Index += (sizeof (AsciiString) - 1)) {\r
-    AsciiStrCpyS (AsciiString, sizeof (AsciiString), &Output[Index]);\r
+    AsciiStrnCpyS (AsciiString, sizeof (AsciiString), &Output[Index], sizeof (AsciiString) - 1);\r
     DEBUG ((DEBUG_INFO, AsciiString));\r
   }\r
 }\r