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.126, mailfrom: ray.ni@intel.com) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by groups.io with SMTP; Tue, 21 May 2019 22:22:33 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2019 22:22:32 -0700 X-ExtLoop1: 1 Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga006.fm.intel.com with ESMTP; 21 May 2019 22:22:32 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 21 May 2019 22:22:32 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 21 May 2019 22:22:31 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.33]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.216]) with mapi id 14.03.0415.000; Wed, 22 May 2019 13:22:29 +0800 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Gao, Zhichao" CC: "Gao, Liming" , "Wu, Hao A" Subject: Re: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix string copy issue Thread-Topic: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix string copy issue Thread-Index: AQHVD6nR0Cvns6V6c0+NydRsAu5oPKZ2nRjA Date: Wed, 22 May 2019 05:22:29 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C1577C0@SHSMSX104.ccr.corp.intel.com> References: <20190521074952.38376-1-zhichao.gao@intel.com> In-Reply-To: <20190521074952.38376-1-zhichao.gao@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Can the library in MdeModulePkg be used? The IntelFrameworkPkg/IntelFrameworkModulePkg will be removed in June. > -----Original Message----- > From: 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 st= ring > 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 > b > +++ ugLib.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); >=20 > // > // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are = for > variable arguments > -- > 2.21.0.windows.1 >=20 >=20 >=20