UnitTestFrameworkPkg/UnitTestResultReportLib: Use AsciiStrnCpyS()

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>
This commit is contained in:
Michael Kubacki 2020-05-21 09:28:40 +08:00 committed by mergify[bot]
parent 1c877c7160
commit 568eee7cf3
2 changed files with 2 additions and 2 deletions

View File

@ -42,7 +42,7 @@ ReportOutput (
Length = AsciiStrLen (Output);
for (Index = 0; Index < Length; Index += (sizeof (AsciiString) - 1)) {
AsciiStrCpyS (AsciiString, sizeof (AsciiString), &Output[Index]);
AsciiStrnCpyS (AsciiString, sizeof (AsciiString), &Output[Index], sizeof (AsciiString) - 1);
ReportPrint ("%a", AsciiString);
}
}

View File

@ -41,7 +41,7 @@ ReportOutput (
Length = AsciiStrLen (Output);
for (Index = 0; Index < Length; Index += (sizeof (AsciiString) - 1)) {
AsciiStrCpyS (AsciiString, sizeof (AsciiString), &Output[Index]);
AsciiStrnCpyS (AsciiString, sizeof (AsciiString), &Output[Index], sizeof (AsciiString) - 1);
DEBUG ((DEBUG_INFO, AsciiString));
}
}