* [PATCH v1 1/1] UnitTestFrameworkPkg/UnitTestResultReportLib: Use AsciiStrnCpyS()
@ 2020-05-21 1:28 Michael Kubacki
2020-05-21 1:45 ` [EXTERNAL] " Bret Barkelew
0 siblings, 1 reply; 2+ messages in thread
From: Michael Kubacki @ 2020-05-21 1:28 UTC (permalink / raw)
To: devel; +Cc: Bret Barkelew, Sean Brogan, Liming Gao, Michael D Kinney
From: Michael Kubacki <michael.kubacki@microsoft.com>
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>
---
UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c | 2 +-
UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c
index 139360ee1657..cfb0c5972bd1 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 743aad2958a7..1402d0ef83e2 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));
}
}
--
2.16.3.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [EXTERNAL] [PATCH v1 1/1] UnitTestFrameworkPkg/UnitTestResultReportLib: Use AsciiStrnCpyS()
2020-05-21 1:28 [PATCH v1 1/1] UnitTestFrameworkPkg/UnitTestResultReportLib: Use AsciiStrnCpyS() Michael Kubacki
@ 2020-05-21 1:45 ` Bret Barkelew
0 siblings, 0 replies; 2+ messages in thread
From: Bret Barkelew @ 2020-05-21 1:45 UTC (permalink / raw)
To: michael.kubacki@outlook.com, devel@edk2.groups.io
Cc: Sean Brogan, liming.gao, Kinney, Michael D
[-- Attachment #1: Type: text/plain, Size: 3469 bytes --]
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
- Bret
________________________________
From: michael.kubacki@outlook.com <michael.kubacki@outlook.com>
Sent: Wednesday, May 20, 2020 6:28:40 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>; liming.gao <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [EXTERNAL] [PATCH v1 1/1] UnitTestFrameworkPkg/UnitTestResultReportLib: Use AsciiStrnCpyS()
From: Michael Kubacki <michael.kubacki@microsoft.com>
REF:https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2721&data=02%7C01%7CBret.Barkelew%40microsoft.com%7C3df7de73c045465745a708d7fd265f00%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637256213561542812&sdata=d28c2VOQ%2FCn53uFUGpddqFtL3lmX9Kir7mvKYm7%2BYEw%3D&reserved=0
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>
---
UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c | 2 +-
UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c
index 139360ee1657..cfb0c5972bd1 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 743aad2958a7..1402d0ef83e2 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));
}
}
--
2.16.3.windows.1
[-- Attachment #2: Type: text/html, Size: 5683 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-21 1:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-21 1:28 [PATCH v1 1/1] UnitTestFrameworkPkg/UnitTestResultReportLib: Use AsciiStrnCpyS() Michael Kubacki
2020-05-21 1:45 ` [EXTERNAL] " Bret Barkelew
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox