]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c
SecurityPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / SecurityPkg / Library / Tpm2CommandLib / Tpm2Sequences.c
index 305b6f20784a9132f38566afb112b87d88a8640f..201c2170fc602d534479db85f4b9c7a576015642 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Implement TPM2 Sequences related command.\r
 \r
-Copyright (c) 2013, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -90,7 +84,7 @@ typedef struct {
   @param[in]  HashAlg           The hash algorithm to use for the hash sequence\r
                                 An Event sequence starts if this is TPM_ALG_NULL.\r
   @param[out] SequenceHandle    A handle to reference the sequence\r
\r
+\r
   @retval EFI_SUCCESS      Operation completed successfully.\r
   @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
 **/\r
@@ -178,7 +172,7 @@ Tpm2HashSequenceStart (
 \r
   @param[in] SequenceHandle    Handle for the sequence object\r
   @param[in] Buffer            Data to be added to hash\r
\r
+\r
   @retval EFI_SUCCESS      Operation completed successfully.\r
   @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
 **/\r
@@ -277,7 +271,7 @@ Tpm2SequenceUpdate (
   @param[in]  SequenceHandle    Authorization for the sequence\r
   @param[in]  Buffer            Data to be added to the Event\r
   @param[out] Results           List of digests computed for the PCR\r
\r
+\r
   @retval EFI_SUCCESS      Operation completed successfully.\r
   @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
 **/\r
@@ -375,6 +369,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
@@ -403,7 +402,7 @@ Tpm2EventSequenceComplete (
   @param[in]  SequenceHandle    Authorization for the sequence\r
   @param[in]  Buffer            Data to be added to the hash/HMAC\r
   @param[out] Result            The returned HMAC or digest in a sized buffer\r
\r
+\r
   @retval EFI_SUCCESS      Operation completed successfully.\r
   @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
 **/\r
@@ -496,6 +495,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