From 43e2395c1b130540820957305451340e1fff81e4 Mon Sep 17 00:00:00 2001 From: Dun Tan Date: Mon, 29 Jul 2024 09:32:19 +0800 Subject: [PATCH] MdeModulePkg: fix issue caused by uninitialized variable 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 --- MdeModulePkg/Universal/Variable/Pei/Variable.c | 1 + 1 file changed, 1 insertion(+) diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c b/MdeModulePkg/Universal/Variable/Pei/Variable.c index 26f95c6d95..9f3d43486c 100644 --- a/MdeModulePkg/Universal/Variable/Pei/Variable.c +++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c @@ -1336,6 +1336,7 @@ CalculateHobVariableCacheSize ( VARIABLE_STORE_HEADER *VariableStoreHeader; VariableStoreHeader = NULL; + ZeroMem (&StoreInfo, sizeof (VARIABLE_STORE_INFO)); GetHobVariableStore (&StoreInfo, &VariableStoreHeader); if (VariableStoreHeader == NULL) {