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.88, mailfrom: liming.gao@intel.com) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by groups.io with SMTP; Wed, 10 Jul 2019 18:47:41 -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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2019 18:47:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,476,1557212400"; d="scan'208";a="341239655" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 10 Jul 2019 18:47:40 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 10 Jul 2019 18:47:40 -0700 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 10 Jul 2019 18:47:39 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.110]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.232]) with mapi id 14.03.0439.000; Thu, 11 Jul 2019 09:47:38 +0800 From: "Liming Gao" To: "Kinney, Michael D" , "devel@edk2.groups.io" , "leif.lindholm@linaro.org" CC: "Gao, Zhichao" , "Feng, Bob C" , Andrew Fish , Laszlo Ersek Subject: Re: [edk2-devel] [Patch v3] BaseTools: Fix GCC compiler failure in new added tools. Thread-Topic: [edk2-devel] [Patch v3] BaseTools: Fix GCC compiler failure in new added tools. Thread-Index: AQHVNoPDhmJkB8riTEG3hZGMIDwagKbD1Czw///vuACAAOO5wA== Date: Thu, 11 Jul 2019 01:47:37 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4A57F7@SHSMSX104.ccr.corp.intel.com> References: <1562666013-13188-1-git-send-email-liming.gao@intel.com> <20190709182559.to6n5pifdkegc7yy@bivouac.eciton.net> <4A89E2EF3DFEDB4C8BFDE51014F606A14E4A53C2@SHSMSX104.ccr.corp.intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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 Mike: Yes. I send the patch and revert them today.=20 Thanks Liming >-----Original Message----- >From: Kinney, Michael D >Sent: Thursday, July 11, 2019 4:10 AM >To: Gao, Liming ; devel@edk2.groups.io; >leif.lindholm@linaro.org; Kinney, Michael D >Cc: Gao, Zhichao ; Feng, Bob C >; Andrew Fish ; Laszlo Ersek > >Subject: RE: [edk2-devel] [Patch v3] BaseTools: Fix GCC compiler failure = in >new added tools. > >Liming, > >I agree that edk2-staging is a good place to work on cleaning >these tools up. > >Please revert the commit of these tools today so GCC builds >are not broken. > >Thanks, > >Mike > >> -----Original Message----- >> From: Gao, Liming >> Sent: Wednesday, July 10, 2019 6:43 AM >> To: devel@edk2.groups.io; leif.lindholm@linaro.org >> Cc: Gao, Zhichao ; Feng, Bob C >> ; Andrew Fish ; >> Laszlo Ersek ; Kinney, Michael D >> >> Subject: RE: [edk2-devel] [Patch v3] BaseTools: Fix GCC >> compiler failure in new added tools. >> >> Lefi: >> >> > -----Original Message----- >> > From: devel@edk2.groups.io >> [mailto:devel@edk2.groups.io] On Behalf Of >> > Leif Lindholm >> > Sent: Wednesday, July 10, 2019 2:26 AM >> > To: devel@edk2.groups.io; Gao, Liming >> >> > Cc: Gao, Zhichao ; Feng, Bob C >> > ; Andrew Fish ; >> Laszlo Ersek >> > ; Kinney, Michael D >> >> > Subject: Re: [edk2-devel] [Patch v3] BaseTools: Fix GCC >> compiler failure in new added tools. >> > >> > Hi Liming, >> > >> > On Tue, Jul 09, 2019 at 05:53:33PM +0800, Liming Gao >> wrote: >> > > From: gaozhic >> > > >> > > GCC 7 or 8 reports some warnings in new added >> FCE/FMMT/BlmLib. >> > >> > Please list the specific warnings addressed. >> > (But also see my comments below - I think this utility >> needs ripping >> > out and rewriting.) >> > >> > > Signed-off-by: Liming Gao >> > > Cc: Bob Feng >> > > --- >> > > In V2: >> > > Fix GCC8 compiler issue. >> > > >> > > In V3: >> > > Fix snprintf wrong replacement. >> > > >> > > BaseTools/Source/C/BfmLib/BfmLib.c | >> 117 +++++++++++---------- >> > > BaseTools/Source/C/FCE/BinaryParse.c | >> 2 +- >> > > BaseTools/Source/C/FMMT/FirmwareModuleManagement.c | >> 2 +- >> > > BaseTools/Source/C/FMMT/FmmtLib.c | >> 117 +++++++++++---------- >> > > 4 files changed, 122 insertions(+), 116 deletions(-) >> > > >> > > diff --git a/BaseTools/Source/C/BfmLib/BfmLib.c >> > > b/BaseTools/Source/C/BfmLib/BfmLib.c >> > > index 9dedda3da2..8d0ec9038c 100644 >> > > --- a/BaseTools/Source/C/BfmLib/BfmLib.c >> > > +++ b/BaseTools/Source/C/BfmLib/BfmLib.c >> > > @@ -9,6 +9,9 @@ >> > > >> > > #include "BinFileManager.h" >> > > >> > > +#define STR_LEN_MAX_4K 4096 >> > > +#define STR_LEN_MAX_1K 1024 >> > > + >> > >> > Coding style 3.3.3: "Code files should not contain >> #define and typedef >> > statements." >> > >> > Move these to BinFileManager.h? >> > >> > > #define EFI_TEST_FFS_ATTRIBUTES_BIT(FvbAttributes, >> TestAttributes, Bit) \ >> > > ( \ >> > > (BOOLEAN) ( \ >> > > @@ -116,7 +119,7 @@ LibInitializeFvStruct ( >> > > >> > > for (Index =3D 0; Index < MAX_NUMBER_OF_FILES_IN_FV; >> Index ++) { >> > > memset (Fv->FfsAttuibutes[Index].FfsName, '\0', >> _MAX_PATH); >> > > - memset (Fv->FfsAttuibutes[Index].UiName, '\0', >> _MAX_PATH); >> > > + memset (Fv->FfsAttuibutes[Index].UiName, '\0', >> _MAX_PATH * >> > > + sizeof (CHAR16)); >> > > >> > > Fv->FfsAttuibutes[Index].IsLeaf =3D >> TRUE; >> > > Fv->FfsAttuibutes[Index].TotalSectionNum =3D >> 0; >> > > @@ -2399,153 +2402,153 @@ LibFvHeaderAttributeToStr ( >> > > >> > > LocalStr =3D NULL; >> > > >> > > - LocalStr =3D (CHAR8 *) malloc (1024 * 4); >> > > + LocalStr =3D (CHAR8 *) malloc (STR_LEN_MAX_4K); >> > > >> > > if (LocalStr =3D=3D NULL) { >> > > printf ("Out of resource, memory allocation >> failed. \n"); >> > > return EFI_OUT_OF_RESOURCES; >> > > } >> > > >> > > - memset (LocalStr, '\0', 1024 * 4); >> > > + memset (LocalStr, '\0', STR_LEN_MAX_4K); >> > > >> > > if (Attr =3D=3D 0 || InfFile =3D=3D NULL) { >> > > free (LocalStr); >> > > return EFI_INVALID_PARAMETER; >> > > } >> > > >> > > - strncat (LocalStr, "[attributes] \n", >> sizeof("[attributes] \n")); >> > > + strncat (LocalStr, "[attributes] \n", >> STR_LEN_MAX_4K - strlen >> > > + (LocalStr) - 1); >> > >> > This is a very inefficient, and difficult to read, way >> of doing this. >> > It also performs absolutely no error checking (making >> any future >> > debugging tedious at best). >> > >> This change is to fix gcc warning -Werror=3Dsizeof-pointer- >> memaccess. >> strncat is the safe version API. So, it is used here. >> >> > I have to be honest - looking at this code, I think the >> right thing to >> > do would be to revert the commit adding it and >> reworking the utility >> > completely (making sure it gets serious review) before >> merging it. >> > >> > I am not surprised the compilers get upset. >> > >> > This made me have a closer look at the patches adding >> FCE and FMMT, >> > and frankly, my opinion of them are similar. These >> aren't being >> > upstreamed - this is textbook "chuck over the wall". >> > >> > Don't get me wrong - the code quality of FMMT is >> notably higher than >> > the code quality of FCE, which is notably higher than >> the code quality >> > of BfmLib. But even >> > >> > BfmLib was added with the comment that it is used by >> FCE. >> > So why do FCE and FMMT both have separate copies of >> LibBfmGuidToStr? >> > Not just functions doing the same thing, but with the >> same name. >> > >> > There are many other issues with these tools. >> >> FCE & FMMT both operate the binary FV image. Their >> implementation may copy the same logic. I don't think >> this is a good way. >> I agree to do better design for code sharing and code >> quality improvement. >> >> I suggest to revert them, add current FCE & FMMT into >> edk2-staging, then refine them, and send the patch to add >> them back into edk2 BaseTools. >> >> Thanks >> Liming >> > >> > / >> > Leif >> > >> > > >> > > if (Attr & EFI_FVB2_READ_DISABLED_CAP) { >> > > - strncat (LocalStr, "EFI_READ_DISABLED_CAP =3D TRUE >> \n", sizeof ("EFI_READ_DISABLED_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_DISABLED_CAP =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_READ_ENABLED_CAP) { >> > > - strncat (LocalStr, "EFI_READ_ENABLED_CAP =3D TRUE >> \n", sizeof ("EFI_READ_ENABLED_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_ENABLED_CAP =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_READ_STATUS) { >> > > - strncat (LocalStr, "EFI_READ_STATUS =3D TRUE \n", >> sizeof ("EFI_READ_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_STATUS =3D TRUE \n", >> STR_LEN_MAX_4K >> > > + - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_WRITE_DISABLED_CAP) { >> > > - strncat (LocalStr, "EFI_WRITE_DISABLED_CAP =3D >> TRUE \n", sizeof ("EFI_WRITE_DISABLED_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_WRITE_DISABLED_CAP =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_WRITE_ENABLED_CAP) { >> > > - strncat (LocalStr, "EFI_WRITE_ENABLED_CAP =3D TRUE >> \n", sizeof ("EFI_WRITE_ENABLED_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_WRITE_ENABLED_CAP =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_WRITE_STATUS) { >> > > - strncat (LocalStr, "EFI_WRITE_STATUS =3D TRUE \n", >> sizeof ("EFI_WRITE_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_WRITE_STATUS =3D TRUE \n", >> STR_LEN_MAX_4K >> > > + - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_LOCK_CAP) { >> > > - strncat (LocalStr, "EFI_LOCK_CAP =3D TRUE \n", >> sizeof ("EFI_LOCK_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_LOCK_CAP =3D TRUE \n", >> STR_LEN_MAX_4K - >> > > + strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_LOCK_STATUS) { >> > > - strncat (LocalStr, "EFI_LOCK_STATUS =3D TRUE \n", >> sizeof ("EFI_LOCK_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_LOCK_STATUS =3D TRUE \n", >> STR_LEN_MAX_4K >> > > + - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_STICKY_WRITE) { >> > > - strncat (LocalStr, "EFI_STICKY_WRITE =3D TRUE \n", >> sizeof ("EFI_STICKY_WRITE =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_STICKY_WRITE =3D TRUE \n", >> STR_LEN_MAX_4K >> > > + - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_MEMORY_MAPPED) { >> > > - strncat (LocalStr, "EFI_MEMORY_MAPPED =3D TRUE >> \n", sizeof ("EFI_MEMORY_MAPPED =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_MEMORY_MAPPED =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_ERASE_POLARITY) { >> > > - strncat (LocalStr, "EFI_ERASE_POLARITY =3D 1 \n", >> sizeof ("EFI_ERASE_POLARITY =3D 1 \n")); >> > > + strncat (LocalStr, "EFI_ERASE_POLARITY =3D 1 \n", >> STR_LEN_MAX_4K >> > > + - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_READ_LOCK_CAP) { >> > > - strncat (LocalStr, "EFI_READ_LOCK_CAP =3D TRUE >> \n", sizeof ("EFI_READ_LOCK_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_LOCK_CAP =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_READ_LOCK_STATUS) { >> > > - strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE >> \n", sizeof ("EFI_READ_LOCK_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_WRITE_LOCK_CAP) { >> > > - strncat (LocalStr, "EFI_WRITE_LOCK_CAP =3D TRUE >> \n", sizeof ("EFI_WRITE_LOCK_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_WRITE_LOCK_CAP =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_WRITE_LOCK_STATUS) { >> > > - strncat (LocalStr, "EFI_WRITE_LOCK_STATUS =3D TRUE >> \n", sizeof ("EFI_WRITE_LOCK_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_WRITE_LOCK_STATUS =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_LOCK_STATUS) { >> > > - strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE >> \n", sizeof ("EFI_READ_LOCK_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > // >> > > // Alignment >> > > // >> > > if (Attr & EFI_FVB2_ALIGNMENT_1) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_1 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_2) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_2 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_4) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_4 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_8) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_8 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_16) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_16 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_32) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_32 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_64) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_64 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_128) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128 =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_128 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128 =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_256) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256 =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_256 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256 =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_512) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512 =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_512 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512 =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_1K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1K =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_1K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1K =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_2K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2K =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_2K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2K =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_4K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4K =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_4K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4K =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_8K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8K =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_8K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8K =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_16K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_16K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_32K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_32K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_64K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_64K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_128K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_128K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_256K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_256K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_512K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_512K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_1M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1M =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_1M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1M =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_2M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2M =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_2M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2M =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_4M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4M =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_4M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4M =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_8M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8M =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_8M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8M =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_16M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_16M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_32M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_32M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_64M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_64M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_128M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_128M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_256M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_256M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_512M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_512M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_1G) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1G =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_1G =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1G =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_2G) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2G =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_2G =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2G =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (fwrite (LocalStr, 1, (size_t) strlen >> (LocalStr), InfFile) !=3D >> > > (size_t) strlen (LocalStr)) { @@ -2592,7 +2595,7 @@ >> LibFvHeaderOptionToStr ( >> > > // >> > > // This section will not over 1024 bytes and each >> line will never over 128 bytes. >> > > // >> > > - LocalStr =3D (CHAR8 *) malloc (1024); >> > > + LocalStr =3D (CHAR8 *) malloc (STR_LEN_MAX_1K); >> > > BlockSize =3D (CHAR8 *) malloc (128); >> > > NumOfBlocks =3D (CHAR8 *) malloc (128); >> > > >> > > @@ -2611,18 +2614,18 @@ LibFvHeaderOptionToStr ( >> > > return EFI_OUT_OF_RESOURCES; >> > > } >> > > >> > > - memset (LocalStr, '\0', 1024); >> > > + memset (LocalStr, '\0', STR_LEN_MAX_1K); >> > > memset (BlockSize, '\0', 128); >> > > memset (NumOfBlocks, '\0', 128); >> > > >> > > - strncat (LocalStr, "[options] \n", >> sizeof("[Options] \n")); >> > > + strncat (LocalStr, "[options] \n", STR_LEN_MAX_1K >> - strlen >> > > + (LocalStr) - 1); >> > > >> > > sprintf (BlockSize, "EFI_BLOCK_SIZE =3D 0x%x \n", >> > > BlockMap->Length); >> > > - strncat (LocalStr, BlockSize, strlen(BlockSize)); >> > > + strncat (LocalStr, BlockSize, STR_LEN_MAX_1K - >> strlen (LocalStr) >> > > + - 1); >> > > >> > > if (IsRootFv) { >> > > sprintf (NumOfBlocks, "EFI_NUM_BLOCKS =3D 0x%x \n", >> > > BlockMap->NumBlocks); >> > > - strncat (LocalStr, NumOfBlocks, >> strlen(NumOfBlocks)); >> > > + strncat (LocalStr, NumOfBlocks, STR_LEN_MAX_1K - >> strlen >> > > + (LocalStr) - 1); >> > > } >> > > >> > > if (fwrite (LocalStr, 1, (size_t) strlen >> (LocalStr), InfFile) !=3D >> > > (size_t) strlen (LocalStr)) { diff --git >> > > a/BaseTools/Source/C/FCE/BinaryParse.c >> > > b/BaseTools/Source/C/FCE/BinaryParse.c >> > > index e9f8ee6826..97d6ecf93b 100644 >> > > --- a/BaseTools/Source/C/FCE/BinaryParse.c >> > > +++ b/BaseTools/Source/C/FCE/BinaryParse.c >> > > @@ -1240,7 +1240,7 @@ Done: >> > > ) { >> > > continue; >> > > } >> > > - sprintf (FileNameArry, "%s%c%s", FolderName, >> OS_SEP, pDirent->d_name); >> > > + snprintf (FileNameArry, MAX_FILENAME_LEN, >> "%s%c%s", >> > > + FolderName, OS_SEP, pDirent->d_name); >> > > FfsFile =3D fopen (FileNameArry, "rb"); >> > > Status =3D ReadFfsHeader (FfsFile, (UINT32 >> *)&FileSize); >> > > if (EFI_ERROR (Status)) { >> > > diff --git >> a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c >> > > b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c >> > > index 63ae3c45a4..6648fbd54f 100644 >> > > --- >> a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c >> > > +++ >> b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c >> > > @@ -1572,7 +1572,7 @@ FmmtImageDelete ( >> > > // If decrease operation >> executed, we should adjust the ffs list. It will bring in >> more complex. >> > > // >> > > //FvInFd->FfsNumbers >> -=3D 1; >> > > - memset(FvInFd- >> >FfsAttuibutes[Index].UiName, '\0', _MAX_PATH); >> > > + memset(FvInFd- >> >FfsAttuibutes[Index].UiName, >> > > + '\0', _MAX_PATH * sizeof (CHAR16)); >> > > if (FvInFd- >> >FfsAttuibutes[Index].FvLevel > 1) { >> > > for (j =3D Index - 1; j >=3D 0; >> j--) { >> > > if (FvInFd- >> >FfsAttuibutes[j].FvLevel =3D=3D >> > > FvInFd->FfsAttuibutes[Index].FvLevel - 1) { diff -- >> git >> > > a/BaseTools/Source/C/FMMT/FmmtLib.c >> > > b/BaseTools/Source/C/FMMT/FmmtLib.c >> > > index f87042114b..e236810c59 100644 >> > > --- a/BaseTools/Source/C/FMMT/FmmtLib.c >> > > +++ b/BaseTools/Source/C/FMMT/FmmtLib.c >> > > @@ -9,6 +9,9 @@ >> > > >> > > #include "FirmwareModuleManagement.h" >> > > >> > > +#define STR_LEN_MAX_4K 4096 >> > > +#define STR_LEN_MAX_1K 1024 >> > > + >> > > #define EFI_TEST_FFS_ATTRIBUTES_BIT(FvbAttributes, >> TestAttributes, Bit) \ >> > > ( \ >> > > (BOOLEAN) ( \ >> > > @@ -155,7 +158,7 @@ LibInitializeFvStruct ( >> > > >> > > for (Index =3D 0; Index < MAX_NUMBER_OF_FILES_IN_FV; >> Index ++) { >> > > memset (Fv->FfsAttuibutes[Index].FfsName, '\0', >> _MAX_PATH); >> > > - memset (Fv->FfsAttuibutes[Index].UiName, '\0', >> _MAX_PATH); >> > > + memset (Fv->FfsAttuibutes[Index].UiName, '\0', >> _MAX_PATH * >> > > + sizeof (CHAR16)); >> > > memset (&Fv->FfsAttuibutes[Index].GuidName, >> '\0', sizeof(EFI_GUID)); >> > > Fv->FfsAttuibutes[Index].UiNameSize =3D >> 0; >> > > Fv->FfsAttuibutes[Index].IsLeaf =3D >> TRUE; >> > > @@ -2504,153 +2507,153 @@ LibFvHeaderAttributeToStr ( >> > > >> > > LocalStr =3D NULL; >> > > >> > > - LocalStr =3D (CHAR8 *) malloc (1024 * 4); >> > > + LocalStr =3D (CHAR8 *) malloc (STR_LEN_MAX_4K); >> > > >> > > if (LocalStr =3D=3D NULL) { >> > > printf ("Memory allocate error!\n"); >> > > return EFI_OUT_OF_RESOURCES; >> > > } >> > > >> > > - memset (LocalStr, '\0', 1024 * 4); >> > > + memset (LocalStr, '\0', STR_LEN_MAX_4K); >> > > >> > > if (Attr =3D=3D 0 || InfFile =3D=3D NULL) { >> > > free (LocalStr); >> > > return EFI_INVALID_PARAMETER; >> > > } >> > > >> > > - strncat (LocalStr, "[attributes] \n", >> sizeof("[attributes] \n")); >> > > + strncat (LocalStr, "[attributes] \n", >> STR_LEN_MAX_4K - strlen >> > > + (LocalStr) - 1); >> > > >> > > if (Attr & EFI_FVB2_READ_DISABLED_CAP) { >> > > - strncat (LocalStr, "EFI_READ_DISABLED_CAP =3D TRUE >> \n", sizeof ("EFI_READ_DISABLED_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_DISABLED_CAP =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_READ_ENABLED_CAP) { >> > > - strncat (LocalStr, "EFI_READ_ENABLED_CAP =3D TRUE >> \n", sizeof ("EFI_READ_ENABLED_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_ENABLED_CAP =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_READ_STATUS) { >> > > - strncat (LocalStr, "EFI_READ_STATUS =3D TRUE \n", >> sizeof ("EFI_READ_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_STATUS =3D TRUE \n", >> STR_LEN_MAX_4K >> > > + - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_WRITE_DISABLED_CAP) { >> > > - strncat (LocalStr, "EFI_WRITE_DISABLED_CAP =3D >> TRUE \n", sizeof ("EFI_WRITE_DISABLED_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_WRITE_DISABLED_CAP =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_WRITE_ENABLED_CAP) { >> > > - strncat (LocalStr, "EFI_WRITE_ENABLED_CAP =3D TRUE >> \n", sizeof ("EFI_WRITE_ENABLED_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_WRITE_ENABLED_CAP =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_WRITE_STATUS) { >> > > - strncat (LocalStr, "EFI_WRITE_STATUS =3D TRUE \n", >> sizeof ("EFI_WRITE_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_WRITE_STATUS =3D TRUE \n", >> STR_LEN_MAX_4K >> > > + - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_LOCK_CAP) { >> > > - strncat (LocalStr, "EFI_LOCK_CAP =3D TRUE \n", >> sizeof ("EFI_LOCK_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_LOCK_CAP =3D TRUE \n", >> STR_LEN_MAX_4K - >> > > + strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_LOCK_STATUS) { >> > > - strncat (LocalStr, "EFI_LOCK_STATUS =3D TRUE \n", >> sizeof ("EFI_LOCK_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_LOCK_STATUS =3D TRUE \n", >> STR_LEN_MAX_4K >> > > + - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_STICKY_WRITE) { >> > > - strncat (LocalStr, "EFI_STICKY_WRITE =3D TRUE \n", >> sizeof ("EFI_STICKY_WRITE =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_STICKY_WRITE =3D TRUE \n", >> STR_LEN_MAX_4K >> > > + - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_MEMORY_MAPPED) { >> > > - strncat (LocalStr, "EFI_MEMORY_MAPPED =3D TRUE >> \n", sizeof ("EFI_MEMORY_MAPPED =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_MEMORY_MAPPED =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_ERASE_POLARITY) { >> > > - strncat (LocalStr, "EFI_ERASE_POLARITY =3D 1 \n", >> sizeof ("EFI_ERASE_POLARITY =3D 1 \n")); >> > > + strncat (LocalStr, "EFI_ERASE_POLARITY =3D 1 \n", >> STR_LEN_MAX_4K >> > > + - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_READ_LOCK_CAP) { >> > > - strncat (LocalStr, "EFI_READ_LOCK_CAP =3D TRUE >> \n", sizeof ("EFI_READ_LOCK_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_LOCK_CAP =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_READ_LOCK_STATUS) { >> > > - strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE >> \n", sizeof ("EFI_READ_LOCK_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_WRITE_LOCK_CAP) { >> > > - strncat (LocalStr, "EFI_WRITE_LOCK_CAP =3D TRUE >> \n", sizeof ("EFI_WRITE_LOCK_CAP =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_WRITE_LOCK_CAP =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_WRITE_LOCK_STATUS) { >> > > - strncat (LocalStr, "EFI_WRITE_LOCK_STATUS =3D TRUE >> \n", sizeof ("EFI_WRITE_LOCK_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_WRITE_LOCK_STATUS =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (Attr & EFI_FVB2_LOCK_STATUS) { >> > > - strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE >> \n", sizeof ("EFI_READ_LOCK_STATUS =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > // >> > > // Alignment >> > > // >> > > if (Attr & EFI_FVB2_ALIGNMENT_1) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_1 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_2) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_2 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_4) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_4 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_8) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_8 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_16) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_16 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_32) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_32 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_64) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64 =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_64 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64 =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_128) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128 =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_128 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128 =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_256) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256 =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_256 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256 =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_512) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512 =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_512 =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512 =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_1K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1K =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_1K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1K =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_2K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2K =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_2K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2K =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_4K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4K =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_4K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4K =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_8K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8K =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_8K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8K =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_16K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_16K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_32K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_32K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_64K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_64K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_128K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_128K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_256K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_256K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_512K) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512K =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_512K =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512K =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_1M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1M =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_1M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1M =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_2M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2M =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_2M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2M =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_4M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4M =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_4M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4M =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_8M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8M =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_8M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8M =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_16M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_16M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_16M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_32M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_32M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_32M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_64M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_64M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_64M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_128M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_128M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_128M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_256M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_256M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_256M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_512M) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512M =3D >> TRUE \n", sizeof ("EFI_FVB2_ALIGNMENT_512M =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_512M =3D >> TRUE \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_1G) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1G =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_1G =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1G =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } else if (Attr & EFI_FVB2_ALIGNMENT_2G) { >> > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2G =3D TRUE >> \n", sizeof ("EFI_FVB2_ALIGNMENT_2G =3D TRUE \n")); >> > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2G =3D TRUE >> \n", >> > > + STR_LEN_MAX_4K - strlen (LocalStr) - 1); >> > > } >> > > >> > > if (fwrite (LocalStr, 1, (size_t) strlen >> (LocalStr), InfFile) !=3D >> > > (size_t) strlen (LocalStr)) { @@ -2696,7 +2699,7 @@ >> LibFvHeaderOptionToStr ( >> > > // >> > > // This section will not over 1024 bytes and each >> line will never over 128 bytes. >> > > // >> > > - LocalStr =3D (CHAR8 *) malloc (1024); >> > > + LocalStr =3D (CHAR8 *) malloc (STR_LEN_MAX_1K); >> > > TempStr =3D (CHAR8 *) malloc (128); >> > > >> > > if (LocalStr =3D=3D NULL || >> > > @@ -2712,18 +2715,18 @@ LibFvHeaderOptionToStr ( >> > > } >> > > >> > > BlockMap =3D FvHeader->BlockMap; >> > > - memset (LocalStr, '\0', 1024); >> > > + memset (LocalStr, '\0', STR_LEN_MAX_1K); >> > > memset (TempStr, '\0', 128); >> > > >> > > - strncat (LocalStr, "[options] \n", >> sizeof("[Options] \n")); >> > > + strncat (LocalStr, "[options] \n", STR_LEN_MAX_1K >> - strlen >> > > + (LocalStr) - 1); >> > > >> > > >> > > snprintf (TempStr, 128, "EFI_BLOCK_SIZE =3D 0x%x >> \n", >> > > BlockMap->Length); >> > > - strncat (LocalStr, TempStr, strlen(TempStr)); >> > > + strncat (LocalStr, TempStr, STR_LEN_MAX_1K - >> strlen (LocalStr) - >> > > + 1); >> > > >> > > if (IsRootFv) { >> > > snprintf (TempStr, 128, "EFI_NUM_BLOCKS =3D 0x%x >> \n", >> > > BlockMap->NumBlocks); >> > > - strncat (LocalStr, TempStr, strlen(TempStr)); >> > > + strncat (LocalStr, TempStr, STR_LEN_MAX_1K - >> strlen (LocalStr) - >> > > + 1); >> > > } >> > > >> > > if (fwrite (LocalStr, 1, (size_t) strlen >> (LocalStr), InfFile) !=3D >> > > (size_t) strlen (LocalStr)) { >> > > -- >> > > 2.13.0.windows.1 >> > > >> > > >> > > >> > > >> > >> >=20