]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm2CommandLib/Tpm2Session.c
SecurityPkg Tpm2CommandLib: Fix TPM2.0 response memory overflow
[mirror_edk2.git] / SecurityPkg / Library / Tpm2CommandLib / Tpm2Session.c
index f03b6689ac02454e09e170469a8b376805b806a1..35ad86a17af9d5bba9a1b5e4f2a136599838f107 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implement TPM2 Session related command.\r
 \r
-Copyright (c) 2014, Intel Corporation. All rights reserved. <BR>\r
+Copyright (c) 2014 - 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
@@ -163,6 +163,11 @@ Tpm2StartAuthSession (
   //\r
   *SessionHandle = SwapBytes32 (RecvBuffer.SessionHandle);\r
   NonceTPM->size = SwapBytes16 (RecvBuffer.NonceTPM.size);\r
+  if (NonceTPM->size > sizeof(TPMU_HA)) {\r
+    DEBUG ((DEBUG_ERROR, "Tpm2StartAuthSession - NonceTPM->size error %x\n", NonceTPM->size));\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
   CopyMem (NonceTPM->buffer, &RecvBuffer.NonceTPM.buffer, NonceTPM->size);\r
 \r
   return EFI_SUCCESS;\r