From 3dc5c1ae5c7575ba2d1714b40692b36fca56c120 Mon Sep 17 00:00:00 2001 From: Thomas Palmer Date: Tue, 5 Apr 2016 03:51:42 +0800 Subject: MdeModulePkg/UefiBootManagerLib: API BmIsValidLoadOptionVariableName Redfine the BmIsValidLoadOptionVariableName function to allow public use. Change name to EfiBootManagerIsValidLoadOptionVariableName to match naming scheme. Check that VariableName is never NULL and allow OptionType and OptionNumber to be optional. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Thomas Palmer Reviewed-by: Sunny Wang Reviewed-by: Ruiyu Ni --- .../Library/UefiBootManagerLib/BmLoadOption.c | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c') diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c index 696e995bb6..8201255484 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c @@ -2,7 +2,7 @@ Load option library functions which relate with creating and processing load options. Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
-(C) Copyright 2015 Hewlett Packard Enterprise Development LP
+(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -775,16 +775,21 @@ BmValidateOption ( @retval FALSE The variable name is NOT valid. **/ BOOLEAN -BmIsValidLoadOptionVariableName ( +EFIAPI +EfiBootManagerIsValidLoadOptionVariableName ( IN CHAR16 *VariableName, - OUT EFI_BOOT_MANAGER_LOAD_OPTION_TYPE *OptionType, - OUT UINT16 *OptionNumber + OUT EFI_BOOT_MANAGER_LOAD_OPTION_TYPE *OptionType OPTIONAL, + OUT UINT16 *OptionNumber OPTIONAL ) { UINTN VariableNameLen; UINTN Index; UINTN Uint; + if (VariableName == NULL) { + return FALSE; + } + VariableNameLen = StrLen (VariableName); if (VariableNameLen <= 4) { @@ -803,14 +808,19 @@ BmIsValidLoadOptionVariableName ( return FALSE; } - *OptionType = (EFI_BOOT_MANAGER_LOAD_OPTION_TYPE) Index; - *OptionNumber = 0; - for (Index = VariableNameLen - 4; Index < VariableNameLen; Index++) { - Uint = BmCharToUint (VariableName[Index]); - if (Uint == -1) { - break; - } else { - *OptionNumber = (UINT16) Uint + *OptionNumber * 0x10; + if (OptionType != NULL) { + *OptionType = (EFI_BOOT_MANAGER_LOAD_OPTION_TYPE) Index; + } + + if (OptionNumber != NULL) { + *OptionNumber = 0; + for (Index = VariableNameLen - 4; Index < VariableNameLen; Index++) { + Uint = BmCharToUint (VariableName[Index]); + if (Uint == -1) { + break; + } else { + *OptionNumber = (UINT16) Uint + *OptionNumber * 0x10; + } } } @@ -853,7 +863,7 @@ EfiBootManagerVariableToLoadOptionEx ( return EFI_INVALID_PARAMETER; } - if (!BmIsValidLoadOptionVariableName (VariableName, &OptionType, &OptionNumber)) { + if (!EfiBootManagerIsValidLoadOptionVariableName (VariableName, &OptionType, &OptionNumber)) { return EFI_INVALID_PARAMETER; } @@ -979,7 +989,7 @@ BmCollectLoadOptions ( if (CompareGuid (Guid, Param->Guid) && ( Param->OptionType == LoadOptionTypePlatformRecovery && - BmIsValidLoadOptionVariableName (Name, &OptionType, &OptionNumber) && + EfiBootManagerIsValidLoadOptionVariableName (Name, &OptionType, &OptionNumber) && OptionType == LoadOptionTypePlatformRecovery )) { Status = EfiBootManagerVariableToLoadOptionEx (Name, Guid, &Option); -- cgit v1.2.3