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.43, mailfrom: liming.gao@intel.com) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by groups.io with SMTP; Wed, 10 Jul 2019 06:42:48 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2019 06:42:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,474,1557212400"; d="scan'208";a="249471805" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga001.jf.intel.com with ESMTP; 10 Jul 2019 06:42:47 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 10 Jul 2019 06:42:47 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 10 Jul 2019 06:42:47 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.110]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.162]) with mapi id 14.03.0439.000; Wed, 10 Jul 2019 21:42:45 +0800 From: "Liming Gao" 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. Thread-Topic: [edk2-devel] [Patch v3] BaseTools: Fix GCC compiler failure in new added tools. Thread-Index: AQHVNoPDhmJkB8riTEG3hZGMIDwagKbD1Czw Date: Wed, 10 Jul 2019 13:42:44 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4A53C2@SHSMSX104.ccr.corp.intel.com> References: <1562666013-13188-1-git-send-email-liming.gao@intel.com> <20190709182559.to6n5pifdkegc7yy@bivouac.eciton.net> In-Reply-To: <20190709182559.to6n5pifdkegc7yy@bivouac.eciton.net> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzdjN2VjMDYtOTg4OS00ZmFiLWJlNTktZGRiMWRiOTcyMDRiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMUNqYUVodGJwaGZ5ZTRrWWxhRGJVUThYWWlvTTFxQzQ4Z1VkY2VhQmYwbHkyZGc5N0RyYlwvdHl1MEZDR3FnY0wifQ== 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 Lefi: > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Le= if 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. >=20 > Hi Liming, >=20 > 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. >=20 > Please list the specific warnings addressed. > (But also see my comments below - I think this utility needs ripping > out and rewriting.) >=20 > > 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/B= fmLib/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 > > + >=20 > Coding style 3.3.3: "Code files should not contain #define and typedef > statements." >=20 > Move these to BinFileManager.h? >=20 > > #define EFI_TEST_FFS_ATTRIBUTES_BIT(FvbAttributes, TestAttributes, Bi= t) \ > > ( \ > > (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 (Loca= lStr) - 1); >=20 > 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). >=20 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. >=20 > I am not surprised the compilers get upset. >=20 > 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". >=20 > 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 >=20 > 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. >=20 > 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.= = =20 I suggest to revert them, add current FCE & FMMT into edk2-staging, then r= efine them, and send the patch to add them back into edk2 BaseTools. Thanks Liming >=20 > / > Leif >=20 > > > > 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_M= AX_4K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_READ_ENABLED_CAP) { > > - strncat (LocalStr, "EFI_READ_ENABLED_CAP =3D TRUE \n", sizeof ("E= FI_READ_ENABLED_CAP =3D TRUE \n")); > > + strncat (LocalStr, "EFI_READ_ENABLED_CAP =3D TRUE \n", STR_LEN_MA= X_4K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_READ_STATUS) { > > - strncat (LocalStr, "EFI_READ_STATUS =3D TRUE \n", sizeof ("EFI_RE= AD_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_M= AX_4K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_WRITE_STATUS) { > > - strncat (LocalStr, "EFI_WRITE_STATUS =3D TRUE \n", sizeof ("EFI_W= RITE_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 - s= trlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_LOCK_STATUS) { > > - strncat (LocalStr, "EFI_LOCK_STATUS =3D TRUE \n", sizeof ("EFI_LO= CK_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_S= TICKY_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_4= K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_ERASE_POLARITY) { > > - strncat (LocalStr, "EFI_ERASE_POLARITY =3D 1 \n", sizeof ("EFI_ER= ASE_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_4= K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_READ_LOCK_STATUS) { > > - strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE \n", sizeof ("E= FI_READ_LOCK_STATUS =3D TRUE \n")); > > + strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE \n", STR_LEN_MA= X_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_M= AX_4K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_LOCK_STATUS) { > > - strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE \n", sizeof ("E= FI_READ_LOCK_STATUS =3D TRUE \n")); > > + strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE \n", STR_LEN_MA= X_4K - strlen (LocalStr) - 1); > > } > > > > // > > // Alignment > > // > > if (Attr & EFI_FVB2_ALIGNMENT_1) { > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1 =3D TRUE \n", sizeof ("E= FI_FVB2_ALIGNMENT_1 =3D TRUE \n")); > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1 =3D TRUE \n", STR_LEN_MA= X_4K - strlen (LocalStr) - 1); > > } else if (Attr & EFI_FVB2_ALIGNMENT_2) { > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2 =3D TRUE \n", sizeof ("E= FI_FVB2_ALIGNMENT_2 =3D TRUE \n")); > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2 =3D TRUE \n", STR_LEN_MA= X_4K - strlen (LocalStr) - 1); > > } else if (Attr & EFI_FVB2_ALIGNMENT_4) { > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4 =3D TRUE \n", sizeof ("E= FI_FVB2_ALIGNMENT_4 =3D TRUE \n")); > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4 =3D TRUE \n", STR_LEN_MA= X_4K - strlen (LocalStr) - 1); > > } else if (Attr & EFI_FVB2_ALIGNMENT_8) { > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8 =3D TRUE \n", sizeof ("E= FI_FVB2_ALIGNMENT_8 =3D TRUE \n")); > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8 =3D TRUE \n", STR_LEN_MA= X_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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 o= ver 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 (LocalSt= r) - 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->NumB= locks); > > - 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/Base= Tools/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 adju= st 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/FM= MT/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, Bi= t) \ > > ( \ > > (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 (Loca= lStr) - 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_M= AX_4K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_READ_ENABLED_CAP) { > > - strncat (LocalStr, "EFI_READ_ENABLED_CAP =3D TRUE \n", sizeof ("E= FI_READ_ENABLED_CAP =3D TRUE \n")); > > + strncat (LocalStr, "EFI_READ_ENABLED_CAP =3D TRUE \n", STR_LEN_MA= X_4K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_READ_STATUS) { > > - strncat (LocalStr, "EFI_READ_STATUS =3D TRUE \n", sizeof ("EFI_RE= AD_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_M= AX_4K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_WRITE_STATUS) { > > - strncat (LocalStr, "EFI_WRITE_STATUS =3D TRUE \n", sizeof ("EFI_W= RITE_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 - s= trlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_LOCK_STATUS) { > > - strncat (LocalStr, "EFI_LOCK_STATUS =3D TRUE \n", sizeof ("EFI_LO= CK_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_S= TICKY_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_4= K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_ERASE_POLARITY) { > > - strncat (LocalStr, "EFI_ERASE_POLARITY =3D 1 \n", sizeof ("EFI_ER= ASE_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_4= K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_READ_LOCK_STATUS) { > > - strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE \n", sizeof ("E= FI_READ_LOCK_STATUS =3D TRUE \n")); > > + strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE \n", STR_LEN_MA= X_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_M= AX_4K - strlen (LocalStr) - 1); > > } > > > > if (Attr & EFI_FVB2_LOCK_STATUS) { > > - strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE \n", sizeof ("E= FI_READ_LOCK_STATUS =3D TRUE \n")); > > + strncat (LocalStr, "EFI_READ_LOCK_STATUS =3D TRUE \n", STR_LEN_MA= X_4K - strlen (LocalStr) - 1); > > } > > > > // > > // Alignment > > // > > if (Attr & EFI_FVB2_ALIGNMENT_1) { > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1 =3D TRUE \n", sizeof ("E= FI_FVB2_ALIGNMENT_1 =3D TRUE \n")); > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_1 =3D TRUE \n", STR_LEN_MA= X_4K - strlen (LocalStr) - 1); > > } else if (Attr & EFI_FVB2_ALIGNMENT_2) { > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2 =3D TRUE \n", sizeof ("E= FI_FVB2_ALIGNMENT_2 =3D TRUE \n")); > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_2 =3D TRUE \n", STR_LEN_MA= X_4K - strlen (LocalStr) - 1); > > } else if (Attr & EFI_FVB2_ALIGNMENT_4) { > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4 =3D TRUE \n", sizeof ("E= FI_FVB2_ALIGNMENT_4 =3D TRUE \n")); > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_4 =3D TRUE \n", STR_LEN_MA= X_4K - strlen (LocalStr) - 1); > > } else if (Attr & EFI_FVB2_ALIGNMENT_8) { > > - strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8 =3D TRUE \n", sizeof ("E= FI_FVB2_ALIGNMENT_8 =3D TRUE \n")); > > + strncat (LocalStr, "EFI_FVB2_ALIGNMENT_8 =3D TRUE \n", STR_LEN_MA= X_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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_M= AX_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 o= ver 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 (LocalSt= r) - 1); > > > > > > snprintf (TempStr, 128, "EFI_BLOCK_SIZE =3D 0x%x \n", BlockMap->Le= ngth); > > - 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->Nu= mBlocks); > > - 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 >=20