From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 D32FA21E11D07 for ; Tue, 29 Aug 2017 00:22:36 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP; 29 Aug 2017 00:25:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,444,1498546800"; d="scan'208";a="143118702" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 29 Aug 2017 00:25:16 -0700 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 29 Aug 2017 00:25:15 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 29 Aug 2017 00:25:15 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.39]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.117]) with mapi id 14.03.0319.002; Tue, 29 Aug 2017 15:25:14 +0800 From: "Dong, Eric" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [PATCH v2] MdeModulePkg/UefiHiiLib: Fix incorrect check for string length Thread-Index: AQHTIJJZhQyoNgKYck+UZp+xPO4d4qKa7q8Q Date: Tue, 29 Aug 2017 07:25:13 +0000 Message-ID: References: <1503989077-330616-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1503989077-330616-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/UefiHiiLib: Fix incorrect check for string length X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Aug 2017 07:22:37 -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=20 Sent: Tuesday, August 29, 2017 2:45 PM To: edk2-devel@lists.01.org Cc: Dong, Eric ; Gao, Liming Subject: [PATCH v2] MdeModulePkg/UefiHiiLib: Fix incorrect check for string= length REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D681 For string opcode,when checking the valid string length, it should exclude = the Null-terminated character. And for string in NameValue storage, need to exclude the varname and also n= eed to convert the Config string length to Unicode string length. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Librar= y/UefiHiiLib/HiiLib.c index cd0cd35..5249392 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -1605,11 +1605,11 @@ ValidateQuestionFromVfr ( IfrString =3D (EFI_IFR_STRING *) IfrOpHdr; if (IfrString->Question.VarStoreId !=3D VarStoreData.VarStoreId)= { break; } // - // Get Width by OneOf Flags + // Get the Max size of the string. // Width =3D (UINT16) (IfrString->MaxSize * sizeof (UINT16)); if (NameValueType) { QuestionName =3D HiiGetString (HiiHandle, IfrString->Question.= VarStoreInfo.VarName, NULL); ASSERT (QuestionName !=3D NULL); @@ -1619,20 +1619,29 @@ Valid= ateQuestionFromVfr ( // // This question is not in the current configuration string.= Skip it. // break; } + // + // Skip the VarName. + // + StringPtr +=3D StrLen (QuestionName); =20 // // Skip the "=3D". //=20 StringPtr +=3D 1; =20 // // Check current string length is less than maxsize + // e.g Config String: "0041004200430044", Unicode String: "ABC= D". Unicode String length =3D Config String length / 4. + // Config string format in UEFI spec. + // ::=3D