]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg VarCheckLib: R18611 was thoughtless for property set
authorStar Zeng <star.zeng@intel.com>
Mon, 19 Oct 2015 06:41:28 +0000 (06:41 +0000)
committerlzeng14 <lzeng14@Edk2>
Mon, 19 Oct 2015 06:41:28 +0000 (06:41 +0000)
R18611 only updated the logic to return correct property
when no property set to variable with wildcard name.
But VariablePropertySet needs the pointer of property data for set.
So roll back the change in VariablePropertyGetWithWildcardName at R18611,
and check the property revision first in VariablePropertyGet and
SetVariableCheck before using the property data.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18626 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Library/VarCheckLib/VarCheckLib.c

index 3d1f8f6f4698aa6d9e5e8c19d08b0899e92546d4..60c141a6b93583eef173c4fdf057929cb0416d49 100644 (file)
@@ -141,19 +141,11 @@ VariablePropertyGetWithWildcardName (
             VarCheckInternalIsHexaDecimalDigitCharacter (VariableName[NameLength + 1]) &&\r
             VarCheckInternalIsHexaDecimalDigitCharacter (VariableName[NameLength + 2]) &&\r
             VarCheckInternalIsHexaDecimalDigitCharacter (VariableName[NameLength + 3])) {\r
-          if (mVarCheckVariableWithWildcardName[Index].VariableProperty.Revision != VAR_CHECK_VARIABLE_PROPERTY_REVISION) {\r
-            return NULL;\r
-          } else {\r
-            return &mVarCheckVariableWithWildcardName[Index].VariableProperty;\r
-          }\r
+          return &mVarCheckVariableWithWildcardName[Index].VariableProperty;\r
         }\r
       }\r
       if (StrCmp (mVarCheckVariableWithWildcardName[Index].Name, VariableName) == 0) {\r
-        if (mVarCheckVariableWithWildcardName[Index].VariableProperty.Revision != VAR_CHECK_VARIABLE_PROPERTY_REVISION) {\r
-          return NULL;\r
-        } else {\r
-          return  &mVarCheckVariableWithWildcardName[Index].VariableProperty;\r
-        }\r
+        return  &mVarCheckVariableWithWildcardName[Index].VariableProperty;\r
       }\r
     }\r
   }\r
@@ -512,6 +504,9 @@ VarCheckLibVariablePropertySet (
 \r
   Status = EFI_SUCCESS;\r
 \r
+  //\r
+  // Get the pointer of property data for set.\r
+  //\r
   Property = VariablePropertyGetFunction (Name, Guid, FALSE);\r
   if (Property != NULL) {\r
     CopyMem (Property, VariableProperty, sizeof (*VariableProperty));\r
@@ -571,7 +566,12 @@ VarCheckLibVariablePropertyGet (
   }\r
 \r
   Property = VariablePropertyGetFunction (Name, Guid, TRUE);\r
-  if (Property != NULL) {\r
+  //\r
+  // Also check the property revision before using the property data.\r
+  // There is no property set to this variable(wildcard name)\r
+  // if the revision is not VAR_CHECK_VARIABLE_PROPERTY_REVISION.\r
+  //\r
+  if ((Property != NULL) && (Property->Revision == VAR_CHECK_VARIABLE_PROPERTY_REVISION)) {\r
     CopyMem (VariableProperty, Property, sizeof (*VariableProperty));\r
     return EFI_SUCCESS;\r
   }\r
@@ -619,7 +619,12 @@ VarCheckLibSetVariableCheck (
   }\r
 \r
   Property = VariablePropertyGetFunction (VariableName, VendorGuid, TRUE);\r
-  if (Property != NULL) {\r
+  //\r
+  // Also check the property revision before using the property data.\r
+  // There is no property set to this variable(wildcard name)\r
+  // if the revision is not VAR_CHECK_VARIABLE_PROPERTY_REVISION.\r
+  //\r
+  if ((Property != NULL) && (Property->Revision == VAR_CHECK_VARIABLE_PROPERTY_REVISION)) {\r
     if ((RequestSource != VarCheckFromTrusted) && ((Property->Property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) != 0)) {\r
       DEBUG ((EFI_D_INFO, "Variable Check ReadOnly variable fail %r - %g:%s\n", EFI_WRITE_PROTECTED, VendorGuid, VariableName));\r
       return EFI_WRITE_PROTECTED;\r