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 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2014, 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
EFI_HOB_GUID_TYPE *GuidHob;\r
UINTN PartialHeaderSize;\r
\r
+ if (Variable == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
//\r
// First assume variable header pointed by Variable is consecutive.\r
//\r
*VariableHeader = Variable;\r
\r
- if ((Variable != NULL) && (StoreInfo->FtwLastWriteData != NULL)) {\r
+ if (StoreInfo->FtwLastWriteData != NULL) {\r
TargetAddress = StoreInfo->FtwLastWriteData->TargetAddress;\r
SpareAddress = StoreInfo->FtwLastWriteData->SpareAddress;\r
+ if (((UINTN) Variable > (UINTN) SpareAddress) &&\r
+ (((UINTN) Variable - (UINTN) SpareAddress + (UINTN) TargetAddress) >= (UINTN) GetEndPointer (StoreInfo->VariableStoreHeader))) {\r
+ //\r
+ // Reach the end of variable store.\r
+ //\r
+ return FALSE;\r
+ }\r
if (((UINTN) Variable < (UINTN) TargetAddress) && (((UINTN) Variable + sizeof (VARIABLE_HEADER)) > (UINTN) TargetAddress)) {\r
//\r
// Variable header pointed by Variable is inconsecutive,\r
CopyMem ((UINT8 *) *VariableHeader + PartialHeaderSize, (UINT8 *) (UINTN) SpareAddress, sizeof (VARIABLE_HEADER) - PartialHeaderSize);\r
}\r
}\r
+ } else {\r
+ if (Variable >= GetEndPointer (StoreInfo->VariableStoreHeader)) {\r
+ //\r
+ // Reach the end of variable store.\r
+ //\r
+ return FALSE;\r
+ }\r
}\r
\r
return IsValidVariableHeader (*VariableHeader);\r