summaryrefslogtreecommitdiffstats
path: root/UnitTestFrameworkPkg
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2020-05-21 09:28:40 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-05-27 02:28:22 +0000
commit568eee7cf319fa95183c8d3b5e8dcf6e078ab8b3 (patch)
treeae8433c298f86844de324e7a3f0178cd1cd2540d /UnitTestFrameworkPkg
parent1c877c716038a862e876cac8f0929bab4a96e849 (diff)
downloadedk2-568eee7cf319fa95183c8d3b5e8dcf6e078ab8b3.tar.gz
edk2-568eee7cf319fa95183c8d3b5e8dcf6e078ab8b3.tar.bz2
edk2-568eee7cf319fa95183c8d3b5e8dcf6e078ab8b3.zip
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>
Diffstat (limited to 'UnitTestFrameworkPkg')
-rw-r--r--UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c2
-rw-r--r--UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c
index 139360ee16..cfb0c5972b 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c
@@ -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);
}
}
diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c
index 743aad2958..1402d0ef83 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c
@@ -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));
}
}