From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 3A19E21C93EC7 for ; Thu, 1 Jun 2017 07:13:42 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jun 2017 07:14:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,280,1493708400"; d="scan'208";a="1155386596" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga001.fm.intel.com with ESMTP; 01 Jun 2017 07:14:43 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 1 Jun 2017 07:14:42 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 1 Jun 2017 07:14:42 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.151]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.56]) with mapi id 14.03.0319.002; Thu, 1 Jun 2017 22:14:39 +0800 From: "Ni, Ruiyu" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Carsey, Jaben" , "Kinney, Michael D" , "Shah, Tapan" Thread-Topic: [edk2] [PATCH] ShellPkg/alias: Fix bug to support upper-case alias Thread-Index: AQHS2uEvx1X9WZ9OnEq8Fo8i+PF4aKIQDPSQ Date: Thu, 1 Jun 2017 14:14:38 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5B981323@SHSMSX104.ccr.corp.intel.com> References: <20170601141136.145340-1-ruiyu.ni@intel.com> In-Reply-To: <20170601141136.145340-1-ruiyu.ni@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] ShellPkg/alias: Fix bug to support upper-case alias 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, 01 Jun 2017 14:13:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Including Tapan for review. Thanks/Ray > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Ruiyu Ni > Sent: Thursday, June 1, 2017 10:12 PM > To: edk2-devel@lists.01.org > Cc: Carsey, Jaben ; Kinney, Michael D > > Subject: [edk2] [PATCH] ShellPkg/alias: Fix bug to support upper-case ali= as >=20 > alias in UEFI Shell is case insensitive. > Old code saves the alias to variable storage without converting the alias= to > lower-case, which results upper case alias setting doesn't work. > The patch converts the alias to lower case before saving to variable stor= age. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ruiyu Ni > Cc: Jaben Carsey > Cc: Michael D Kinney > --- > ShellPkg/Application/Shell/ShellProtocol.c | 50 +++++++++++++++---------= ---- > -- > 1 file changed, 25 insertions(+), 25 deletions(-) >=20 > diff --git a/ShellPkg/Application/Shell/ShellProtocol.c > b/ShellPkg/Application/Shell/ShellProtocol.c > index 347e162e62..b3b8acc0d0 100644 > --- a/ShellPkg/Application/Shell/ShellProtocol.c > +++ b/ShellPkg/Application/Shell/ShellProtocol.c > @@ -3463,40 +3463,40 @@ InternalSetAlias( { > EFI_STATUS Status; > CHAR16 *AliasLower; > + BOOLEAN DeleteAlias; >=20 > - // Convert to lowercase to make aliases case-insensitive > - if (Alias !=3D NULL) { > - AliasLower =3D AllocateCopyPool (StrSize (Alias), Alias); > - if (AliasLower =3D=3D NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - ToLower (AliasLower); > - } else { > - AliasLower =3D NULL; > - } > - > - // > - // We must be trying to remove one if Alias is NULL > - // > + DeleteAlias =3D FALSE; > if (Alias =3D=3D NULL) { > // > + // We must be trying to remove one if Alias is NULL > // remove an alias (but passed in COMMAND parameter) > // > - Status =3D (gRT->SetVariable((CHAR16*)Command, &gShellAliasGuid, 0, = 0, > NULL)); > - } else { > - // > - // Add and replace are the same > - // > - > - // We dont check the error return on purpose since the variable may = not > exist. > - gRT->SetVariable((CHAR16*)Command, &gShellAliasGuid, 0, 0, NULL); > + Alias =3D Command; > + DeleteAlias =3D TRUE; > + } > + ASSERT (Alias !=3D NULL); >=20 > - Status =3D (gRT->SetVariable((CHAR16*)Alias, &gShellAliasGuid, > EFI_VARIABLE_BOOTSERVICE_ACCESS|(Volatile?0:EFI_VARIABLE_NON_VOL > ATILE), StrSize(Command), (VOID*)Command)); > + // > + // Convert to lowercase to make aliases case-insensitive // > + AliasLower =3D AllocateCopyPool (StrSize (Alias), Alias); if > + (AliasLower =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > } > + ToLower (AliasLower); >=20 > - if (Alias !=3D NULL) { > - FreePool (AliasLower); > + if (DeleteAlias) { > + Status =3D gRT->SetVariable (AliasLower, &gShellAliasGuid, 0, 0, > + NULL); } else { > + Status =3D gRT->SetVariable ( > + AliasLower, &gShellAliasGuid, > + EFI_VARIABLE_BOOTSERVICE_ACCESS | (Volatile ? 0 : > EFI_VARIABLE_NON_VOLATILE), > + StrSize (Command), (VOID *) Command > + ); > } > + > + FreePool (AliasLower); > + > return Status; > } >=20 > -- > 2.12.2.windows.2 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel