diff options
author | Star Zeng <star.zeng@intel.com> | 2015-10-19 06:41:28 +0000 |
---|---|---|
committer | lzeng14 <lzeng14@Edk2> | 2015-10-19 06:41:28 +0000 |
commit | d2dbe5b70bfbd93211d2ad9503a934d64102410b (patch) | |
tree | 0c390f588bc6dc4e012b56329ad5164caa28a933 | |
parent | 3a2e6a740dff2dd2978264af17cc26f5b56e6623 (diff) | |
download | edk2-d2dbe5b70bfbd93211d2ad9503a934d64102410b.tar.gz edk2-d2dbe5b70bfbd93211d2ad9503a934d64102410b.tar.bz2 edk2-d2dbe5b70bfbd93211d2ad9503a934d64102410b.zip |
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.
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
-rw-r--r-- | MdeModulePkg/Library/VarCheckLib/VarCheckLib.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c index 3d1f8f6f46..60c141a6b9 100644 --- a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c +++ b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c @@ -141,19 +141,11 @@ VariablePropertyGetWithWildcardName ( 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 @@ VarCheckLibVariablePropertySet ( 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 @@ VarCheckLibVariablePropertyGet ( }
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 @@ VarCheckLibSetVariableCheck ( }
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;
|