From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,280,1493708400"; d="scan'208";a="268979286" 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 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Jaben Carsey , Michael D Kinney 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: [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:11:38 -0000 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/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; - // Convert to lowercase to make aliases case-insensitive - if (Alias != NULL) { - AliasLower = AllocateCopyPool (StrSize (Alias), Alias); - if (AliasLower == NULL) { - return EFI_OUT_OF_RESOURCES; - } - ToLower (AliasLower); - } else { - AliasLower = NULL; - } - - // - // We must be trying to remove one if Alias is NULL - // + DeleteAlias = FALSE; if (Alias == NULL) { // + // We must be trying to remove one if Alias is NULL // remove an alias (but passed in COMMAND parameter) // - Status = (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 = Command; + DeleteAlias = TRUE; + } + ASSERT (Alias != NULL); - Status = (gRT->SetVariable((CHAR16*)Alias, &gShellAliasGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS|(Volatile?0:EFI_VARIABLE_NON_VOLATILE), StrSize(Command), (VOID*)Command)); + // + // Convert to lowercase to make aliases case-insensitive + // + AliasLower = AllocateCopyPool (StrSize (Alias), Alias); + if (AliasLower == NULL) { + return EFI_OUT_OF_RESOURCES; } + ToLower (AliasLower); - if (Alias != NULL) { - FreePool (AliasLower); + if (DeleteAlias) { + Status = gRT->SetVariable (AliasLower, &gShellAliasGuid, 0, 0, NULL); + } else { + Status = gRT->SetVariable ( + AliasLower, &gShellAliasGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | (Volatile ? 0 : EFI_VARIABLE_NON_VOLATILE), + StrSize (Command), (VOID *) Command + ); } + + FreePool (AliasLower); + return Status; } -- 2.12.2.windows.2