From cdc83ccf7195c66c77b869ee62155108e39a0246 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Mon, 27 Jul 2015 00:49:00 +0000 Subject: MdeModulePkg Variable: Read MonotonicCount by ReadUnaligned64() As variable HEADER_ALIGNMENT = 4, the MonotonicCount in AUTHENTICATED_VARIABLE_HEADER may be not UINT64 aligned, so go to use ReadUnaligned64() to ensure read data correctly. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Jiewen Yao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18064 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c index 9067f64f15..615b4cec28 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c @@ -67,7 +67,7 @@ VariableExLibFindVariable ( if (mVariableModuleGlobal->VariableGlobal.AuthFormat) { AuthVariable = (AUTHENTICATED_VARIABLE_HEADER *) Variable.CurrPtr; AuthVariableInfo->PubKeyIndex = AuthVariable->PubKeyIndex; - AuthVariableInfo->MonotonicCount = AuthVariable->MonotonicCount; + AuthVariableInfo->MonotonicCount = ReadUnaligned64 (&(AuthVariable->MonotonicCount)); AuthVariableInfo->TimeStamp = &AuthVariable->TimeStamp; } @@ -129,7 +129,7 @@ VariableExLibFindNextVariable ( if (mVariableModuleGlobal->VariableGlobal.AuthFormat) { AuthVariablePtr = (AUTHENTICATED_VARIABLE_HEADER *) VariablePtr; AuthVariableInfo->PubKeyIndex = AuthVariablePtr->PubKeyIndex; - AuthVariableInfo->MonotonicCount = AuthVariablePtr->MonotonicCount; + AuthVariableInfo->MonotonicCount = ReadUnaligned64 (&(AuthVariablePtr->MonotonicCount)); AuthVariableInfo->TimeStamp = &AuthVariablePtr->TimeStamp; } -- cgit v1.2.3