From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: hao.a.wu@intel.com) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by groups.io with SMTP; Tue, 21 May 2019 01:03:26 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2019 01:03:25 -0700 X-ExtLoop1: 1 Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga005.jf.intel.com with ESMTP; 21 May 2019 01:03:25 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 21 May 2019 01:03:24 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 21 May 2019 01:03:24 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.33]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.213]) with mapi id 14.03.0415.000; Tue, 21 May 2019 16:03:21 +0800 From: "Wu, Hao A" To: "devel@edk2.groups.io" , "Gao, Zhichao" CC: "Gao, Liming" Subject: Re: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix string copy issue Thread-Topic: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix string copy issue Thread-Index: AQHVD6nM4MxAS3+djkGmdGefIh4i5aZ1N+LQ Date: Tue, 21 May 2019 08:03:21 +0000 Message-ID: References: <20190521074952.38376-1-zhichao.gao@intel.com> In-Reply-To: <20190521074952.38376-1-zhichao.gao@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: hao.a.wu@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----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 >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1826 >=20 > 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. >=20 > Cc: Liming Gao > Cc: Hao A Wu > Signed-off-by: Zhichao Gao > --- > .../Library/PeiDxeDebugLibReportStatusCode/DebugLib.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > 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 =3D (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12); >=20 > // > - // 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 =3D 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 Best Regards, Hao Wu >=20 > // > // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are = for > variable arguments > -- > 2.21.0.windows.1 >=20 >=20 >=20