]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/VarCheckLib/VarCheckLib.c
MdeModulePkg VarCheckLib: R18611 was thoughtless for property set
[mirror_edk2.git] / 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