From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3A29282157 for ; Tue, 21 Feb 2017 00:20:55 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2017 00:20:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,188,1484035200"; d="scan'208";a="68272254" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga006.fm.intel.com with ESMTP; 21 Feb 2017 00:20:54 -0800 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 21 Feb 2017 00:20:54 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 21 Feb 2017 00:20:53 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX103.ccr.corp.intel.com ([10.239.4.69]) with mapi id 14.03.0248.002; Tue, 21 Feb 2017 16:20:51 +0800 From: "Dong, Eric" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [PATCH v2] MdeModulePkg/HiiDatabase: clean the value before setting default string Thread-Index: AQHSi+n6iZDv8k6fwUWpxaORl4i2SaFzHuZg Date: Tue, 21 Feb 2017 08:20:51 +0000 Message-ID: References: <1487643976-279528-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1487643976-279528-1-git-send-email-dandan.bi@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] MdeModulePkg/HiiDatabase: clean the value before setting default string X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Feb 2017 08:20:55 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong > -----Original Message----- > From: Bi, Dandan > Sent: Tuesday, February 21, 2017 10:26 AM > To: edk2-devel@lists.01.org > Cc: Dong, Eric; Gao, Liming > Subject: [PATCH v2] MdeModulePkg/HiiDatabase: clean the value before sett= ing default string >=20 > For string op-code, the default string may not reach the > maximum size, so when generating string, we should > clean the value before setting the default string. >=20 > V2: Add check for default string size. >=20 > Cc: Eric Dong > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Dandan Bi > --- > MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 17 +++++++++++++= ++-- > 1 file changed, 15 insertions(+), 2 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeM= odulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > index d547f42..ccf4b5a 100644 > --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > @@ -1,9 +1,9 @@ > /** @file > Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCO= L. >=20 > -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D License > which accompanies this distribution. The full text of the license may b= e found at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -3579,10 +3579,11 @@ GenerateAltConfigResp ( > IFR_DEFAULT_DATA *DefaultId; > IFR_DEFAULT_DATA *DefaultValueData; > UINTN Width; > UINT8 *TmpBuffer; > CHAR16 *DefaultString; > + UINTN StrSize; >=20 > BlockData =3D NULL; > DataExist =3D FALSE; > DefaultString =3D NULL; > // > @@ -3696,21 +3697,33 @@ GenerateAltConfigResp ( > // Convert Value to a hex string in "%x" format > // NOTE: This is in the opposite byte that GUID and PATH use > // > if (BlockData->OpCode =3D=3D EFI_IFR_STRING_OP){ > DefaultString =3D InternalGetString(HiiHandle, DefaultValueD= ata->Value.string); > - TmpBuffer =3D (UINT8 *) DefaultString; > + TmpBuffer =3D AllocateZeroPool (Width); > + ASSERT (TmpBuffer !=3D NULL); > + if (DefaultString !=3D NULL) { > + StrSize =3D StrLen(DefaultString)* sizeof (CHAR16); > + if (StrSize > Width) { > + StrSize =3D Width; > + } > + CopyMem (TmpBuffer, (UINT8 *) DefaultString, StrSize); > + } > } else { > TmpBuffer =3D (UINT8 *) &(DefaultValueData->Value); > } > for (; Width > 0 && (TmpBuffer !=3D NULL); Width--) { > StringPtr +=3D UnicodeValueToString (StringPtr, PREFIX_ZERO | = RADIX_HEX, TmpBuffer[Width - 1], 2); > } > if (DefaultString !=3D NULL){ > FreePool(DefaultString); > DefaultString =3D NULL; > } > + if (BlockData->OpCode =3D=3D EFI_IFR_STRING_OP && TmpBuffer !=3D= NULL) { > + FreePool(TmpBuffer); > + TmpBuffer =3D NULL; > + } > } > } > } >=20 > HiiToLower (*DefaultAltCfgResp); > -- > 1.9.5.msysgit.1