From nobody Tue Apr 30 16:50:41 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503989100882579.4277685447017; Mon, 28 Aug 2017 23:45:00 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4AD6321E2BE52; Mon, 28 Aug 2017 23:42:18 -0700 (PDT) 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 64C6021E2BE2C for ; Mon, 28 Aug 2017 23:42:17 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP; 28 Aug 2017 23:44:57 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga001.jf.intel.com with ESMTP; 28 Aug 2017 23:44:56 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,444,1498546800"; d="scan'208";a="1167127452" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 29 Aug 2017 14:44:37 +0800 Message-Id: <1503989077-330616-1-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [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: , Cc: Eric Dong , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 need 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 Reviewed-by: Eric Dong --- 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 @@ ValidateQuestionFromVfr ( // // 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