From e19eab615305b1490b2dee0de0360736be10f9a7 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Fri, 13 May 2016 13:00:01 +0800 Subject: 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 Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Jiewen Yao --- MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'MdeModulePkg/Universal/Variable/RuntimeDxe') diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 3f0240bc07..17475be323 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -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); -- cgit v1.2.3