]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg Variable: return error for empty str VariableName to GetVariable
authorStar Zeng <star.zeng@intel.com>
Fri, 13 May 2016 05:00:01 +0000 (13:00 +0800)
committerStar Zeng <star.zeng@intel.com>
Sun, 15 May 2016 09:48:53 +0000 (17:48 +0800)
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>
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
MdeModulePkg/Universal/Variable/Pei/Variable.c
MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c

index 977332e1cf4999a58ded7276f2bcc2d9c92e13ea..27ea1496a04419b874e96ce9ed7110b679b3d685 100644 (file)
@@ -3,7 +3,7 @@
   Emulation Variable services operate on the runtime volatile memory.\r
   The nonvolatile variable space doesn't exist.\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1183,6 +1183,10 @@ EmuGetVariable (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  if (VariableName[0] == 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
   AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
 \r
   //\r
index c68a41ddfe7dcb57b8479d54241774c8ad49af6d..a072c31e60e74c89683503e5716cf6dd32f40ea2 100644 (file)
@@ -2,7 +2,7 @@
   Implement ReadOnly Variable Services required by PEIM and install\r
   PEI ReadOnly Varaiable2 PPI. These services operates the non volatile storage space.\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -978,6 +978,10 @@ PeiGetVariable (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  if (VariableName[0] == 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
   VariableHeader = NULL;\r
 \r
   //\r
index 3f0240bc072f6ef2e5bd4e7eacfb7ae6e09a8368..17475be323866f3e1a4b462731150e606f33738c 100644 (file)
@@ -2849,6 +2849,10 @@ VariableServiceGetVariable (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  if (VariableName[0] == 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
   AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);\r
 \r
   Status = FindVariable (VariableName, VendorGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, FALSE);\r