From nobody Sat Dec 28 10:49:05 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.zoho.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 149632636330543.70821856636394; Thu, 1 Jun 2017 07:12:43 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9523621AE30CE; Thu, 1 Jun 2017 07:11:38 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 F083B21AE30CE for ; Thu, 1 Jun 2017 07:11:37 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jun 2017 07:11:39 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.1]) by fmsmga004.fm.intel.com with ESMTP; 01 Jun 2017 07:11:38 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,280,1493708400"; d="scan'208";a="268979286" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Thu, 1 Jun 2017 22:11:36 +0800 Message-Id: <20170601141136.145340-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 Subject: [edk2] [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: , Cc: Jaben Carsey , Michael D Kinney 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" 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 storage. 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(-) diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Applicat= ion/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 no= t 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_VAR= IABLE_BOOTSERVICE_ACCESS|(Volatile?0:EFI_VARIABLE_NON_VOLATILE), StrSize(Co= mmand), (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 --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel