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 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,444,1498546800"; d="scan'208";a="1167127452" 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 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Eric Dong , Liming Gao 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: [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 06:42:17 -0000 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=681 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 --- MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/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 = (EFI_IFR_STRING *) IfrOpHdr; if (IfrString->Question.VarStoreId != VarStoreData.VarStoreId) { break; } // - // Get Width by OneOf Flags + // Get the Max size of the string. // Width = (UINT16) (IfrString->MaxSize * sizeof (UINT16)); if (NameValueType) { QuestionName = HiiGetString (HiiHandle, IfrString->Question.VarStoreInfo.VarName, NULL); ASSERT (QuestionName != NULL); @@ -1619,20 +1619,29 @@ ValidateQuestionFromVfr ( // // This question is not in the current configuration string. Skip it. // break; } + // + // Skip the VarName. + // + StringPtr += StrLen (QuestionName); // // Skip the "=". // StringPtr += 1; // // Check current string length is less than maxsize + // e.g Config String: "0041004200430044", Unicode String: "ABCD". Unicode String length = Config String length / 4. + // Config string format in UEFI spec. + // ::=