From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: liming.gao@intel.com) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by groups.io with SMTP; Tue, 21 May 2019 18:55:48 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2019 18:55:47 -0700 X-ExtLoop1: 1 Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga005.fm.intel.com with ESMTP; 21 May 2019 18:55:47 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 21 May 2019 18:55:47 -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; Wed, 22 May 2019 09:55:45 +0800 From: "Liming Gao" To: "Wu, Hao A" , "devel@edk2.groups.io" , "Gao, Zhichao" Subject: Re: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix string copy issue Thread-Topic: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix string copy issue Thread-Index: AQHVD6nP1XaLPuWA6ECQNBBlN97btaZ0seCAgAGxqMA= Date: Wed, 22 May 2019 01:55:45 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E44F3D2@SHSMSX104.ccr.corp.intel.com> References: <20190521074952.38376-1-zhichao.gao@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTgxZDlmMmQtYjNlYy00M2E4LWE4M2YtMTIyN2M3ODExYTI3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMEV5bFVqazduUlBWV1c1M0I5cE9yQTlQdVwvcExNY3RUVWx6RUorSWZFZnM0N2wwd0VucFJxRGZEVXN0U2pzSjEifQ== dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Wu, Hao A > Sent: Tuesday, May 21, 2019 4:03 PM > To: devel@edk2.groups.io; Gao, Zhichao > Cc: Gao, Liming > Subject: RE: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix = string copy issue >=20 > > -----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=3D1826 > > > > 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 > > Cc: Hao A Wu > > Signed-off-by: Zhichao Gao > > --- > > .../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 =3D (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 si= ze 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), Forma= t, > > DestBufferSize / sizeof (CHAR8) - 1); >=20 > Reviewed-by: Hao A Wu >=20 > Best Regards, > Hao Wu >=20 > > > > // > > // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO ar= e for > > variable arguments > > -- > > 2.21.0.windows.1 > > > > > >=20