]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c
SecurityPkg Tpm2CommandLib: Fix TPM2.0 response memory overflow
[mirror_edk2.git] / SecurityPkg / Library / Tpm2CommandLib / Tpm2Sequences.c
index 305b6f20784a9132f38566afb112b87d88a8640f..90877768d3afcc53e9291865ae2c924f2b1633bf 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implement TPM2 Sequences related command.\r
 \r
-Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>\r
+Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -375,6 +375,11 @@ Tpm2EventSequenceComplete (
 \r
   // count\r
   Results->count = SwapBytes32(ReadUnaligned32 ((UINT32 *)BufferPtr));\r
+  if (Results->count > HASH_COUNT) {\r
+    DEBUG ((DEBUG_ERROR, "Tpm2EventSequenceComplete - Results->count error %x\n", Results->count));\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
   BufferPtr += sizeof(UINT32);\r
 \r
   for (Index = 0; Index < Results->count; Index++) {\r
@@ -496,6 +501,11 @@ Tpm2SequenceComplete (
 \r
   // digestSize\r
   Result->size = SwapBytes16(ReadUnaligned16 ((UINT16 *)BufferPtr));\r
+  if (Result->size > sizeof(TPMU_HA)){\r
+    DEBUG ((DEBUG_ERROR, "Tpm2SequenceComplete - Result->size error %x\n", Result->size));\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
   BufferPtr += sizeof(UINT16);\r
 \r
   CopyMem(\r