mirror of https://github.com/acidanthera/audk.git
ShellPkg/alias: Fix bug to support upper-case alias
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 <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Tapan Shah <tapandshah@hpe.com>
This commit is contained in:
parent
a04ec6d9f7
commit
7ec69844b8
|
@ -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));
|
||||
Alias = Command;
|
||||
DeleteAlias = TRUE;
|
||||
}
|
||||
ASSERT (Alias != NULL);
|
||||
|
||||
//
|
||||
// Convert to lowercase to make aliases case-insensitive
|
||||
//
|
||||
AliasLower = AllocateCopyPool (StrSize (Alias), Alias);
|
||||
if (AliasLower == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
ToLower (AliasLower);
|
||||
|
||||
if (DeleteAlias) {
|
||||
Status = gRT->SetVariable (AliasLower, &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);
|
||||
|
||||
Status = (gRT->SetVariable((CHAR16*)Alias, &gShellAliasGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS|(Volatile?0:EFI_VARIABLE_NON_VOLATILE), StrSize(Command), (VOID*)Command));
|
||||
Status = gRT->SetVariable (
|
||||
AliasLower, &gShellAliasGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | (Volatile ? 0 : EFI_VARIABLE_NON_VOLATILE),
|
||||
StrSize (Command), (VOID *) Command
|
||||
);
|
||||
}
|
||||
|
||||
if (Alias != NULL) {
|
||||
FreePool (AliasLower);
|
||||
}
|
||||
FreePool (AliasLower);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue