X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=SecurityPkg%2FTcg%2FTcgDxe%2FTpmComm.c;h=96732fad5d895ef1fd4b25345d7e91238d0062a3;hb=c1d932429ef9700a2da64452546be14e92468b07;hp=c47794b4f6ba9555f4eabb5c898a193294d66c54;hpb=0c18794ea4289f03fefc7117b56740414cc0536c;p=mirror_edk2.git diff --git a/SecurityPkg/Tcg/TcgDxe/TpmComm.c b/SecurityPkg/Tcg/TcgDxe/TpmComm.c index c47794b4f6..96732fad5d 100644 --- a/SecurityPkg/Tcg/TcgDxe/TpmComm.c +++ b/SecurityPkg/Tcg/TcgDxe/TpmComm.c @@ -1,7 +1,7 @@ /** @file Utility functions used by TPM Dxe driver. -Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -144,10 +144,17 @@ TpmCommLogEvent ( IN UINT8 *NewEventData ) { - UINT32 NewLogSize; + UINTN NewLogSize; + + // + // Prevent Event Overflow + // + if (NewEventHdr->EventSize > (UINTN)(~0) - sizeof (*NewEventHdr)) { + return EFI_OUT_OF_RESOURCES; + } NewLogSize = sizeof (*NewEventHdr) + NewEventHdr->EventSize; - if (NewLogSize + *LogSize > MaxSize) { + if (NewLogSize > MaxSize - *LogSize) { return EFI_OUT_OF_RESOURCES; }