MdeModulePkg Variable: return error for empty str VariableName to GetVariable

Current GetVariable implementation will return the first variable for
empty str VariableName, it is because GetVariable and GetNextVariablename
are sharing same function FindVariable.
But UEFI sepc defines SetVariable that If VariableName is an empty string,
then EFI_INVALID_PARAMETER is returned, that means an empty string variable
could never be set successfully, so GetVariable should return error for
empty string VariableName.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Star Zeng 2016-05-13 13:00:01 +08:00
parent dde4aedc35
commit e19eab6153
3 changed files with 14 additions and 2 deletions

View File

@ -3,7 +3,7 @@
Emulation Variable services operate on the runtime volatile memory.
The nonvolatile variable space doesn't exist.
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
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
@ -1183,6 +1183,10 @@ EmuGetVariable (
return EFI_INVALID_PARAMETER;
}
if (VariableName[0] == 0) {
return EFI_NOT_FOUND;
}
AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);
//

View File

@ -2,7 +2,7 @@
Implement ReadOnly Variable Services required by PEIM and install
PEI ReadOnly Varaiable2 PPI. These services operates the non volatile storage space.
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
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
@ -978,6 +978,10 @@ PeiGetVariable (
return EFI_INVALID_PARAMETER;
}
if (VariableName[0] == 0) {
return EFI_NOT_FOUND;
}
VariableHeader = NULL;
//

View File

@ -2849,6 +2849,10 @@ VariableServiceGetVariable (
return EFI_INVALID_PARAMETER;
}
if (VariableName[0] == 0) {
return EFI_NOT_FOUND;
}
AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
Status = FindVariable (VariableName, VendorGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, FALSE);