From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.6278.1589012893484094516 for ; Sat, 09 May 2020 01:28:13 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: ray.ni@intel.com) IronPort-SDR: WMeuDhvYxaBaYDO2GKNn7bkAwer72sHhBLW4zBpihcRR6nZAgp7YHQvKSHO7EXPGOhiThjffmL 4pPqIC2bwX1A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2020 01:28:12 -0700 IronPort-SDR: NUv5q6f/rVafa+YB1F9cr3FsfSbtcFigDqKQdimPWS1BwTTZgbEYEIrlfkmz/7oouXN/hl/LUV rEEPMCB+qcwA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,371,1583222400"; d="scan'208";a="340037886" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga001.jf.intel.com with ESMTP; 09 May 2020 01:28:12 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 9 May 2020 01:28:11 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 9 May 2020 01:28:11 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.210]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.225]) with mapi id 14.03.0439.000; Sat, 9 May 2020 16:28:08 +0800 From: "Ni, Ray" To: "Feng, YunhuaX" , "devel@edk2.groups.io" CC: "Gao, Liming" , "Feng, Bob C" Subject: Re: [edk2-staging][PATCH v2] BaseTools/Fmmt: Fix found the next FFS issue Thread-Topic: [edk2-staging][PATCH v2] BaseTools/Fmmt: Fix found the next FFS issue Thread-Index: AdYlz89dvAIJPsIDT6WNyOCkUfkoiQAC0kXg Date: Sat, 9 May 2020 08:28:07 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C530E94@SHSMSX104.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action 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 Yunhua, I understand that if the ffs size 0 should be specially handled because otherwise the for-loop will be infinite. But why do you need to check the size against 0xFFFFFF? Why the break condition in for-loop " (*Key + sizeof (*fhdr)) < fvSize;" ca= nnot help when the fsize is too big such as 0xFFFFFF? I suggest you explain what issue you want to fix and how this fixes the iss= ue in commit message in detail. Thanks, Ray > -----Original Message----- > From: Feng, YunhuaX > Sent: Saturday, May 9, 2020 3:03 PM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Gao, Liming ; Feng,= Bob C > Subject: [edk2-staging][PATCH v2] BaseTools/Fmmt: Fix found the next FFS = issue >=20 > if the ffs size is invalid, break the iteration and return NOT_FOUND. >=20 > Cc: Ray Ni< ray.ni@intel.com> > Cc: Bob Feng > Cc: Liming Gao >=20 > Change-Id: I9e320d6176af350ff208901209f3f6c89e4e1924 > Signed-off-by: Yunhua Feng > --- > BaseTools/Source/C/FMMT/FmmtLib.c | 7 +++++++ > 1 file changed, 7 insertions(+) >=20 > diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/= FmmtLib.c > index 9ec511ef06..6858cfe778 100644 > --- a/BaseTools/Source/C/FMMT/FmmtLib.c > +++ b/BaseTools/Source/C/FMMT/FmmtLib.c > @@ -1769,10 +1769,17 @@ FvBufFindNextFile ( > (*Key + sizeof (*fhdr)) < fvSize; > *Key =3D (UINTN)ALIGN_POINTER (*Key, 8) > ) { > fhdr =3D (EFI_FFS_FILE_HEADER*) ((UINT8*)hdr + *Key); > fsize =3D GetFfsFileLength (fhdr); > + // > + //if the ffs size is invalid, break the loop > + //the size defined in EFI_FFS_FILE_HEADER is 3 bytes. > + // > + if (fsize =3D=3D (UINTN)((FvbAttributes & EFI_FVB2_ERASE_POLARITY) ?= 0xFFFFFF : 0x0)) { > + break; > + } > if (!EFI_TEST_FFS_ATTRIBUTES_BIT( > FvbAttributes, > fhdr->State, > EFI_FILE_HEADER_VALID > ) || > -- > 2.12.2.windows.2 >=20