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 7593621CFA60C for ; Thu, 24 Aug 2017 01:33:12 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP; 24 Aug 2017 01:35:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,420,1498546800"; d="scan'208";a="141474017" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga005.jf.intel.com with ESMTP; 24 Aug 2017 01:35:46 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 24 Aug 2017 01:35:46 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 24 Aug 2017 01:35:46 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.183]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.128]) with mapi id 14.03.0319.002; Thu, 24 Aug 2017 16:35:44 +0800 From: "Bi, Dandan" To: Wim Vervoorn , "edk2-devel@lists.01.org" Thread-Topic: HiiValidateSettings issue with string item Thread-Index: AdMcpNentLeKDSmqQfmCOUmOTFDv3gAC830g Date: Thu, 24 Aug 2017 08:35:44 +0000 Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB3B9567D4@shsmsx102.ccr.corp.intel.com> References: <03b999a0727d4026a810530b59caeba5@Eltsrv03.Eltan.local> In-Reply-To: <03b999a0727d4026a810530b59caeba5@Eltsrv03.Eltan.local> 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: HiiValidateSettings issue with string item 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: Thu, 24 Aug 2017 08:33:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Wim Vervoorn, Thanks for reporting this issue. It's a bug of current code and your soluti= on can fix it correctly.=20 But when the storage is NameValueType, for string opcode, current code also= calculate the string length incorrectly, the length should not include the= trailing terminator and storage name.=20 So could you help to file a bug on bugzilla and then we can fix these issue= s? https://bugzilla.tianocore.org/ Thanks, Dandan -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Wim = Vervoorn Sent: Thursday, August 24, 2017 2:59 PM To: edk2-devel@lists.01.org Subject: [edk2] HiiValidateSettings issue with string item Hello, I am running into an issue with HiiValidateSettings (); when my VFR contain= s a string item that is filled with a string of maximum length. In this cas= e the validation returns an error because it thinks the string is too long. During the validation ValidateQuestionFromVfr (); checks if the stringlengt= h is valid. The issue is that this uses the "maxsize" value * 2 from the VF= R. It does this using the StrSize function which includes the trailing term= inator. This is of course correct. The maxsize from the VFR indicates only = the amount of characters excluding the terminator. As a quickfix I changed the ValidateQuestionFromVfr () to take this into ac= count but I am doubting if this is the correct solution. Can you shed some = light here? Below is the fragment where I see this issue: // // Get Offset/Width by Question header and OneOf Flags // Offset =3D IfrString->Question.VarStoreInfo.VarOffset; // // Check whether this question is in current block array. // if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { // // This question is not in the current configuration string. = Skip it. // break; } // // Check this var question is in the var storage // if ((Offset + Width) > VarStoreData.Size) { // // This question exceeds the var store size. // return EFI_INVALID_PARAMETER; } // // Check current string length is less than maxsize // // Please note we subtract sizeof(CHAR16) here because the StrS= ize returns the length including the terminator // while we specify the length in characters in the VFR! // ORG -> // if ( (StrSize ((CHAR16 *) (VarBuffer + Offset)) >= Width) { CHANGED-> if ( (StrSize ((CHAR16 *) (VarBuffer + Offset)) - size= of(CHAR16)) > Width) { return EFI_INVALID_PARAMETER; } } break; Best Regards, Wim Vervoorn Eltan B.V. Ambachtstraat 23 5481 SM Schijndel The Netherlands T : +31-(0)73-594 46 64 E : wvervoorn@eltan.com W : http://www.eltan.com "THIS MESSAGE CONTAINS CONFIDENTIAL INFORMATION. UNLESS YOU ARE THE INTENDE= D RECIPIENT OF THIS MESSAGE, ANY USE OF THIS MESSAGE IS STRICTLY PROHIBITED= . IF YOU HAVE RECEIVED THIS MESSAGE IN ERROR, PLEASE IMMEDIATELY NOTIFY THE= SENDER BY TELEPHONE +31-(0)73-5944664 OR REPLY EMAIL, AND IMMEDIATELY DELE= TE THIS MESSAGE AND ALL COPIES." _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel