Skip to content

Commit

Permalink
MdeModulePkg: fix issue caused by uninitialized variable
Browse files Browse the repository at this point in the history
This patch is to fix issue caused by uninitialized local
variable in Pei/Variable.c.

In the fucntion CalculateHobVariableCacheSize(), the local
variable VARIABLE_STORE_INFO StoreInfo is used without
initialization. When the uninitialized variable is passed
to CalculateAuthVarStorageSize() and GetNextVariablePtr(),
the field StoreInfo->FtwLastWriteData might be a uninitialized
non-zero value. Then the code execution will access the
invalid address StoreInfo->FtwLastWriteData->TargetAddress.
This might cause issue.

So in this commit, the local variable VARIABLE_STORE_INFO
StoreInfo is initialized by a ZeroMem() before use.

Signed-off-by: Dun Tan <dun.tan@intel.com>
  • Loading branch information
td36 authored and mergify[bot] committed Jul 29, 2024
1 parent 51edd48 commit 43e2395
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions MdeModulePkg/Universal/Variable/Pei/Variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,7 @@ CalculateHobVariableCacheSize (
VARIABLE_STORE_HEADER *VariableStoreHeader;

VariableStoreHeader = NULL;
ZeroMem (&StoreInfo, sizeof (VARIABLE_STORE_INFO));
GetHobVariableStore (&StoreInfo, &VariableStoreHeader);

if (VariableStoreHeader == NULL) {
Expand Down

0 comments on commit 43e2395

Please sign in to comment.