summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/Variable
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2016-05-13 13:00:01 +0800
committerStar Zeng <star.zeng@intel.com>2016-05-15 17:48:53 +0800
commite19eab615305b1490b2dee0de0360736be10f9a7 (patch)
tree217f677739314a9dfae6ccf29c86c1700a6b9e3e /MdeModulePkg/Universal/Variable
parentdde4aedc35ee3c06b67c1a5c4f392e7a0b0f8254 (diff)
downloadedk2-e19eab615305b1490b2dee0de0360736be10f9a7.tar.gz
edk2-e19eab615305b1490b2dee0de0360736be10f9a7.tar.bz2
edk2-e19eab615305b1490b2dee0de0360736be10f9a7.zip
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>
Diffstat (limited to 'MdeModulePkg/Universal/Variable')
-rw-r--r--MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c6
-rw-r--r--MdeModulePkg/Universal/Variable/Pei/Variable.c6
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c4
3 files changed, 14 insertions, 2 deletions
diff --git a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
index 977332e1cf..27ea1496a0 100644
--- a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
+++ b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
@@ -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);
//
diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c b/MdeModulePkg/Universal/Variable/Pei/Variable.c
index c68a41ddfe..a072c31e60 100644
--- a/MdeModulePkg/Universal/Variable/Pei/Variable.c
+++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c
@@ -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;
//
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);