Revision: 18802
          http://sourceforge.net/p/edk2/code/18802
Author:   vanjeff
Date:     2015-11-16 07:18:36 +0000 (Mon, 16 Nov 2015)
Log Message:
-----------
MdeModulePkg VarCheckLib: R18611 was thoughtless for property set

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.

(Sync patch r18626 from main trunk.)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <[email protected]>
Reviewed-by: Jiewen Yao <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/18611
    http://sourceforge.net/p/edk2/code/18611
    http://sourceforge.net/p/edk2/code/18611
    http://sourceforge.net/p/edk2/code/18626

Modified Paths:
--------------
    branches/UDK2015/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c

Modified: branches/UDK2015/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c
===================================================================
--- branches/UDK2015/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c     
2015-11-16 07:17:53 UTC (rev 18801)
+++ branches/UDK2015/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c     
2015-11-16 07:18:36 UTC (rev 18802)
@@ -141,19 +141,11 @@
             VarCheckInternalIsHexaDecimalDigitCharacter 
(VariableName[NameLength + 1]) &&
             VarCheckInternalIsHexaDecimalDigitCharacter 
(VariableName[NameLength + 2]) &&
             VarCheckInternalIsHexaDecimalDigitCharacter 
(VariableName[NameLength + 3])) {
-          if 
(mVarCheckVariableWithWildcardName[Index].VariableProperty.Revision != 
VAR_CHECK_VARIABLE_PROPERTY_REVISION) {
-            return NULL;
-          } else {
-            return &mVarCheckVariableWithWildcardName[Index].VariableProperty;
-          }
+          return &mVarCheckVariableWithWildcardName[Index].VariableProperty;
         }
       }
       if (StrCmp (mVarCheckVariableWithWildcardName[Index].Name, VariableName) 
== 0) {
-        if (mVarCheckVariableWithWildcardName[Index].VariableProperty.Revision 
!= VAR_CHECK_VARIABLE_PROPERTY_REVISION) {
-          return NULL;
-        } else {
-          return  &mVarCheckVariableWithWildcardName[Index].VariableProperty;
-        }
+        return  &mVarCheckVariableWithWildcardName[Index].VariableProperty;
       }
     }
   }
@@ -512,6 +504,9 @@
 
   Status = EFI_SUCCESS;
 
+  //
+  // Get the pointer of property data for set.
+  //
   Property = VariablePropertyGetFunction (Name, Guid, FALSE);
   if (Property != NULL) {
     CopyMem (Property, VariableProperty, sizeof (*VariableProperty));
@@ -571,7 +566,12 @@
   }
 
   Property = VariablePropertyGetFunction (Name, Guid, TRUE);
-  if (Property != NULL) {
+  //
+  // Also check the property revision before using the property data.
+  // There is no property set to this variable(wildcard name)
+  // if the revision is not VAR_CHECK_VARIABLE_PROPERTY_REVISION.
+  //
+  if ((Property != NULL) && (Property->Revision == 
VAR_CHECK_VARIABLE_PROPERTY_REVISION)) {
     CopyMem (VariableProperty, Property, sizeof (*VariableProperty));
     return EFI_SUCCESS;
   }
@@ -619,7 +619,12 @@
   }
 
   Property = VariablePropertyGetFunction (VariableName, VendorGuid, TRUE);
-  if (Property != NULL) {
+  //
+  // Also check the property revision before using the property data.
+  // There is no property set to this variable(wildcard name)
+  // if the revision is not VAR_CHECK_VARIABLE_PROPERTY_REVISION.
+  //
+  if ((Property != NULL) && (Property->Revision == 
VAR_CHECK_VARIABLE_PROPERTY_REVISION)) {
     if ((RequestSource != VarCheckFromTrusted) && ((Property->Property & 
VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) != 0)) {
       DEBUG ((EFI_D_INFO, "Variable Check ReadOnly variable fail %r - 
%g:%s\n", EFI_WRITE_PROTECTED, VendorGuid, VariableName));
       return EFI_WRITE_PROTECTED;


------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to