.../Library/PeiDxeDebugLibReportStatusCode/DebugLib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1826
There is a bug to use AsciiStrCpyS to copy a truncated
string. If would cause an assert because the truncated
length is always less than the source string length. It
should use the AsciiStrnCpyS instead.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
.../Library/PeiDxeDebugLibReportStatusCode/DebugLib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index e92601f89e..1840b6d683 100644
--- a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
+++ b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
@@ -150,7 +150,7 @@ DebugPrintMarker (
FormatString = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);
//
- // Copy the Format string into the record
+ // Copy the Format string into the record. It will be truncated if it's too long.
//
// According to the content structure of Buffer shown above, the size of
// the FormatString buffer is the size of Buffer minus the Padding
@@ -158,7 +158,7 @@ DebugPrintMarker (
// variable arguments (12 * sizeof (UINT64)).
//
DestBufferSize = sizeof (Buffer) - 4 - sizeof (EFI_DEBUG_INFO) - 12 * sizeof (UINT64);
- AsciiStrCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format);
+ AsciiStrnCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format, DestBufferSize / sizeof (CHAR8) - 1);
//
// The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments
--
2.21.0.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#41115): https://edk2.groups.io/g/devel/message/41115
Mute This Topic: https://groups.io/mt/31694427/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Can the library in MdeModulePkg be used? The IntelFrameworkPkg/IntelFrameworkModulePkg will be removed in June. > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Gao, > Zhichao > Sent: Tuesday, May 21, 2019 3:50 PM > To: devel@edk2.groups.io > Cc: Gao, Liming <liming.gao@intel.com>; Wu, Hao A <hao.a.wu@intel.com> > Subject: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix > string copy issue > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1826 > > There is a bug to use AsciiStrCpyS to copy a truncated string. If would cause > an assert because the truncated length is always less than the source string > length. It should use the AsciiStrnCpyS instead. > > Cc: Liming Gao <liming.gao@intel.com> > Cc: Hao A Wu <hao.a.wu@intel.com> > Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> > --- > .../Library/PeiDxeDebugLibReportStatusCode/DebugLib.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git > a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > bugLib.c > b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > bugLib.c > index e92601f89e..1840b6d683 100644 > --- > a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > bugLib.c > +++ > b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > b > +++ ugLib.c > @@ -150,7 +150,7 @@ DebugPrintMarker ( > FormatString = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12); > > // > - // Copy the Format string into the record > + // Copy the Format string into the record. It will be truncated if it's too long. > // > // According to the content structure of Buffer shown above, the size of > // the FormatString buffer is the size of Buffer minus the Padding @@ - > 158,7 +158,7 @@ DebugPrintMarker ( > // variable arguments (12 * sizeof (UINT64)). > // > DestBufferSize = sizeof (Buffer) - 4 - sizeof (EFI_DEBUG_INFO) - 12 * sizeof > (UINT64); > - AsciiStrCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format); > + AsciiStrnCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format, > + DestBufferSize / sizeof (CHAR8) - 1); > > // > // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for > variable arguments > -- > 2.21.0.windows.1 > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#41192): https://edk2.groups.io/g/devel/message/41192 Mute This Topic: https://groups.io/mt/31694427/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Yes. MdeModulePkg one is correct. The issue is only in IntelFrameworkModulePkg one. This is a regression issue. Before remove IntelFrameworkModulePkg, it is still required to be fixed. Thanks Liming > -----Original Message----- > From: Ni, Ray > Sent: Wednesday, May 22, 2019 1:22 PM > To: devel@edk2.groups.io; Gao, Zhichao <zhichao.gao@intel.com> > Cc: Gao, Liming <liming.gao@intel.com>; Wu, Hao A <hao.a.wu@intel.com> > Subject: RE: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix string copy issue > > Can the library in MdeModulePkg be used? > The IntelFrameworkPkg/IntelFrameworkModulePkg will be removed in June. > > > -----Original Message----- > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Gao, > > Zhichao > > Sent: Tuesday, May 21, 2019 3:50 PM > > To: devel@edk2.groups.io > > Cc: Gao, Liming <liming.gao@intel.com>; Wu, Hao A <hao.a.wu@intel.com> > > Subject: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix > > string copy issue > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1826 > > > > There is a bug to use AsciiStrCpyS to copy a truncated string. If would cause > > an assert because the truncated length is always less than the source string > > length. It should use the AsciiStrnCpyS instead. > > > > Cc: Liming Gao <liming.gao@intel.com> > > Cc: Hao A Wu <hao.a.wu@intel.com> > > Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> > > --- > > .../Library/PeiDxeDebugLibReportStatusCode/DebugLib.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git > > a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > > bugLib.c > > b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > > bugLib.c > > index e92601f89e..1840b6d683 100644 > > --- > > a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > > bugLib.c > > +++ > > b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > > b > > +++ ugLib.c > > @@ -150,7 +150,7 @@ DebugPrintMarker ( > > FormatString = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12); > > > > // > > - // Copy the Format string into the record > > + // Copy the Format string into the record. It will be truncated if it's too long. > > // > > // According to the content structure of Buffer shown above, the size of > > // the FormatString buffer is the size of Buffer minus the Padding @@ - > > 158,7 +158,7 @@ DebugPrintMarker ( > > // variable arguments (12 * sizeof (UINT64)). > > // > > DestBufferSize = sizeof (Buffer) - 4 - sizeof (EFI_DEBUG_INFO) - 12 * sizeof > > (UINT64); > > - AsciiStrCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format); > > + AsciiStrnCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format, > > + DestBufferSize / sizeof (CHAR8) - 1); > > > > // > > // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for > > variable arguments > > -- > > 2.21.0.windows.1 > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#41193): https://edk2.groups.io/g/devel/message/41193 Mute This Topic: https://groups.io/mt/31694427/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
> -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Gao, Zhichao > Sent: Tuesday, May 21, 2019 3:50 PM > To: devel@edk2.groups.io > Cc: Gao, Liming; Wu, Hao A > Subject: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix > string copy issue > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1826 > > There is a bug to use AsciiStrCpyS to copy a truncated > string. If would cause an assert because the truncated > length is always less than the source string length. It > should use the AsciiStrnCpyS instead. > > Cc: Liming Gao <liming.gao@intel.com> > Cc: Hao A Wu <hao.a.wu@intel.com> > Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> > --- > .../Library/PeiDxeDebugLibReportStatusCode/DebugLib.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git > a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > bugLib.c > b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > bugLib.c > index e92601f89e..1840b6d683 100644 > --- > a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > bugLib.c > +++ > b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > bugLib.c > @@ -150,7 +150,7 @@ DebugPrintMarker ( > FormatString = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12); > > // > - // Copy the Format string into the record > + // Copy the Format string into the record. It will be truncated if it's too long. > // > // According to the content structure of Buffer shown above, the size of > // the FormatString buffer is the size of Buffer minus the Padding > @@ -158,7 +158,7 @@ DebugPrintMarker ( > // variable arguments (12 * sizeof (UINT64)). > // > DestBufferSize = sizeof (Buffer) - 4 - sizeof (EFI_DEBUG_INFO) - 12 * sizeof > (UINT64); > - AsciiStrCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format); > + AsciiStrnCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format, > DestBufferSize / sizeof (CHAR8) - 1); Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Best Regards, Hao Wu > > // > // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for > variable arguments > -- > 2.21.0.windows.1 > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#41116): https://edk2.groups.io/g/devel/message/41116 Mute This Topic: https://groups.io/mt/31694427/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: Liming Gao <liming.gao@intel.com> > -----Original Message----- > From: Wu, Hao A > Sent: Tuesday, May 21, 2019 4:03 PM > To: devel@edk2.groups.io; Gao, Zhichao <zhichao.gao@intel.com> > Cc: Gao, Liming <liming.gao@intel.com> > Subject: RE: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix string copy issue > > > -----Original Message----- > > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > > Gao, Zhichao > > Sent: Tuesday, May 21, 2019 3:50 PM > > To: devel@edk2.groups.io > > Cc: Gao, Liming; Wu, Hao A > > Subject: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix > > string copy issue > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1826 > > > > There is a bug to use AsciiStrCpyS to copy a truncated > > string. If would cause an assert because the truncated > > length is always less than the source string length. It > > should use the AsciiStrnCpyS instead. > > > > Cc: Liming Gao <liming.gao@intel.com> > > Cc: Hao A Wu <hao.a.wu@intel.com> > > Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> > > --- > > .../Library/PeiDxeDebugLibReportStatusCode/DebugLib.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git > > a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > > bugLib.c > > b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > > bugLib.c > > index e92601f89e..1840b6d683 100644 > > --- > > a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > > bugLib.c > > +++ > > b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/De > > bugLib.c > > @@ -150,7 +150,7 @@ DebugPrintMarker ( > > FormatString = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12); > > > > // > > - // Copy the Format string into the record > > + // Copy the Format string into the record. It will be truncated if it's too long. > > // > > // According to the content structure of Buffer shown above, the size of > > // the FormatString buffer is the size of Buffer minus the Padding > > @@ -158,7 +158,7 @@ DebugPrintMarker ( > > // variable arguments (12 * sizeof (UINT64)). > > // > > DestBufferSize = sizeof (Buffer) - 4 - sizeof (EFI_DEBUG_INFO) - 12 * sizeof > > (UINT64); > > - AsciiStrCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format); > > + AsciiStrnCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format, > > DestBufferSize / sizeof (CHAR8) - 1); > > Reviewed-by: Hao A Wu <hao.a.wu@intel.com> > > Best Regards, > Hao Wu > > > > > // > > // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for > > variable arguments > > -- > > 2.21.0.windows.1 > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#41184): https://edk2.groups.io/g/devel/message/41184 Mute This Topic: https://groups.io/mt/31694427/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.