From a9f1b2e2d708ed98aa47d576a81d947dc7b79fac Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Wed, 16 Nov 2016 17:17:36 +0800 Subject: [PATCH] SecurityPkg Tcg2Dxe: Get correct digest list size Current code uses GetDigestListSize(DigestList) to get digest list size, that is incorrect. The code should get digest list size of digests copied into event2 log, those digests are compacted, so GetDigestListBinSize() should be used. Cc: Jiewen Yao Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Jiewen Yao --- SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c index 3d79a07d12..6241c5208b 100644 --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c @@ -974,6 +974,7 @@ TcgDxeLogHashEvent ( EFI_STATUS RetStatus; TCG_PCR_EVENT2 TcgPcrEvent2; UINT8 *DigestBuffer; + UINT32 *EventSizePtr; DEBUG ((EFI_D_INFO, "SupportedEventLogs - 0x%08x\n", mTcgDxeData.BsCap.SupportedEventLogs)); @@ -1010,9 +1011,8 @@ TcgDxeLogHashEvent ( TcgPcrEvent2.PCRIndex = NewEventHdr->PCRIndex; TcgPcrEvent2.EventType = NewEventHdr->EventType; DigestBuffer = (UINT8 *)&TcgPcrEvent2.Digest; - DigestBuffer = CopyDigestListToBuffer (DigestBuffer, DigestList, mTcgDxeData.BsCap.ActivePcrBanks); - CopyMem (DigestBuffer, &NewEventHdr->EventSize, sizeof(NewEventHdr->EventSize)); - DigestBuffer = DigestBuffer + sizeof(NewEventHdr->EventSize); + EventSizePtr = CopyDigestListToBuffer (DigestBuffer, DigestList, mTcgDxeData.BsCap.ActivePcrBanks); + CopyMem (EventSizePtr, &NewEventHdr->EventSize, sizeof(NewEventHdr->EventSize)); // // Enter critical region @@ -1021,7 +1021,7 @@ TcgDxeLogHashEvent ( Status = TcgDxeLogEvent ( mTcg2EventInfo[Index].LogFormat, &TcgPcrEvent2, - sizeof(TcgPcrEvent2.PCRIndex) + sizeof(TcgPcrEvent2.EventType) + GetDigestListSize (DigestList) + sizeof(TcgPcrEvent2.EventSize), + sizeof(TcgPcrEvent2.PCRIndex) + sizeof(TcgPcrEvent2.EventType) + GetDigestListBinSize (DigestBuffer) + sizeof(TcgPcrEvent2.EventSize), NewEventData, NewEventHdr->EventSize );