From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ml01.01.org (Postfix) with ESMTP id A1F6A1A1DF5 for ; Thu, 11 Aug 2016 03:52:32 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 11 Aug 2016 03:52:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,504,1464678000"; d="scan'208";a="1039253427" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 11 Aug 2016 03:52:32 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 11 Aug 2016 03:52:31 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 11 Aug 2016 03:52:31 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.150]) with mapi id 14.03.0248.002; Thu, 11 Aug 2016 18:52:29 +0800 From: "Gao, Liming" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Dong, Eric" Thread-Topic: [edk2] [PATCH v2] MdeModulePkg/Browser: Enhance the logic when getting value from AltResp Thread-Index: AQHR87ZlPPe8zUnsDkibnKNWC75lr6BDlWow Date: Thu, 11 Aug 2016 10:52:28 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A1155EA3AF@shsmsx102.ccr.corp.intel.com> References: <1470909250-104752-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1470909250-104752-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/Browser: Enhance the logic when getting value from AltResp 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: Thu, 11 Aug 2016 10:52:32 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Dandan Bi > Sent: Thursday, August 11, 2016 5:54 PM > To: edk2-devel@lists.01.org > Cc: Dong, Eric ; Gao, Liming > Subject: [edk2] [PATCH v2] MdeModulePkg/Browser: Enhance the logic > when getting value from AltResp >=20 > This patch is to enhance SetupBrowser to handle following two cases: > 1. When searching BlockName in AltResp, the hex digits of related > BlockName > in AltResp may be in uppercase. > 2. When converting the Value in AltResp to HiiValue, the length of value > string is bigger than the length of StorageWidth of the question. >=20 > Notes: > V2: > - Add some comments to make the logic clear. >=20 > Cc: Liming Gao > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Dandan Bi > Reviewed-by: Eric Dong > --- > MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 61 > +++++++++++++++----------- > 1 file changed, 35 insertions(+), 26 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > index 66c4313..cd3c8cc 100644 > --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > @@ -1427,44 +1427,48 @@ BufferToValue ( > } > TempChar =3D *StringPtr; > *StringPtr =3D L'\0'; >=20 > LengthStr =3D StrLen (Value); > + > + // > + // Value points to a Unicode hexadecimal string, we need to convert th= e > string to the value with CHAR16/UINT8...type. > + // When generating the Value string, we follow this rule: 1 byte -> 2 > Unicode characters (for string: 2 byte(CHAR16) ->4 Unicode characters). > + // So the maximum value string length of a question is : Question- > >StorageWidth * 2. > + // If the value string length > Question->StorageWidth * 2, only set t= he > string length as Question->StorageWidth * 2, then convert. > + // > + if (LengthStr > (UINTN) Question->StorageWidth * 2) { > + Length =3D (UINTN) Question->StorageWidth * 2; > + } else { > + Length =3D LengthStr; > + } > + > Status =3D EFI_SUCCESS; > if (!IsBufferStorage && IsString) { > // > // Convert Config String to Unicode String, e.g "0041004200430044" = =3D> > "ABCD" > // Add string tail char L'\0' into Length > // > - Length =3D Question->StorageWidth + sizeof (CHAR16); > - if (Length < ((LengthStr / 4 + 1) * 2)) { > - Status =3D EFI_BUFFER_TOO_SMALL; > - } else { > - DstBuf =3D (CHAR16 *) Dst; > - ZeroMem (TemStr, sizeof (TemStr)); > - for (Index =3D 0; Index < LengthStr; Index +=3D 4) { > - StrnCpyS (TemStr, sizeof (TemStr) / sizeof (CHAR16), Value + Ind= ex, 4); > - DstBuf[Index/4] =3D (CHAR16) StrHexToUint64 (TemStr); > - } > - // > - // Add tailing L'\0' character > - // > - DstBuf[Index/4] =3D L'\0'; > + DstBuf =3D (CHAR16 *) Dst; > + ZeroMem (TemStr, sizeof (TemStr)); > + for (Index =3D 0; Index < Length; Index +=3D 4) { > + StrnCpyS (TemStr, sizeof (TemStr) / sizeof (CHAR16), Value + Index= , 4); > + DstBuf[Index/4] =3D (CHAR16) StrHexToUint64 (TemStr); > } > + // > + // Add tailing L'\0' character > + // > + DstBuf[Index/4] =3D L'\0'; > } else { > - if (Question->StorageWidth < ((LengthStr + 1) / 2)) { > - Status =3D EFI_BUFFER_TOO_SMALL; > - } else { > - ZeroMem (TemStr, sizeof (TemStr)); > - for (Index =3D 0; Index < LengthStr; Index ++) { > - TemStr[0] =3D Value[LengthStr - Index - 1]; > - DigitUint8 =3D (UINT8) StrHexToUint64 (TemStr); > - if ((Index & 1) =3D=3D 0) { > - Dst [Index/2] =3D DigitUint8; > - } else { > - Dst [Index/2] =3D (UINT8) ((DigitUint8 << 4) + Dst [Index/2]); > - } > + ZeroMem (TemStr, sizeof (TemStr)); > + for (Index =3D 0; Index < Length; Index ++) { > + TemStr[0] =3D Value[LengthStr - Index - 1]; > + DigitUint8 =3D (UINT8) StrHexToUint64 (TemStr); > + if ((Index & 1) =3D=3D 0) { > + Dst [Index/2] =3D DigitUint8; > + } else { > + Dst [Index/2] =3D (UINT8) ((DigitUint8 << 4) + Dst [Index/2]); > } > } > } >=20 > *StringPtr =3D TempChar; > @@ -3755,10 +3759,15 @@ GetOffsetFromConfigResp ( > // > // Type is EFI_HII_VARSTORE_EFI_VARIABLE or > EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER > // >=20 > // > + // Convert all hex digits in ConfigResp to lower case before searching= . > + // > + HiiToLower (ConfigResp); > + > + // > // 1. Directly use Question->BlockName to find. > // > RequestElement =3D StrStr (ConfigResp, Question->BlockName); > if (RequestElement !=3D NULL) { > // > -- > 1.9.5.msysgit.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel