]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c
SecurityPkg: Add TPM PTP detection in TPM12 device lib.
[mirror_edk2.git] / SecurityPkg / Library / Tpm2CommandLib / Tpm2Integrity.c
index 88dcc0afe221ba172d8a3a57809dbb67e31f9056..fa4318dd5fba707466933ee8a60b7c89c31e5aad 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implement TPM2 Integrity related command.\r
 \r
-Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>\r
+Copyright (c) 2013 - 2016, 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
@@ -470,7 +470,7 @@ Tpm2PcrAllocate (
     WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(PcrAllocation->pcrSelections[Index].hash));\r
     Buffer += sizeof(UINT16);\r
     *(UINT8 *)Buffer = PcrAllocation->pcrSelections[Index].sizeofSelect;\r
-    Buffer += sizeof(UINT8);\r
+    Buffer++;\r
     CopyMem (Buffer, PcrAllocation->pcrSelections[Index].pcrSelect, PcrAllocation->pcrSelections[Index].sizeofSelect);\r
     Buffer += PcrAllocation->pcrSelections[Index].sizeofSelect;\r
   }\r
@@ -490,10 +490,14 @@ Tpm2PcrAllocate (
              &ResultBufSize,\r
              ResultBuf\r
              );\r
+  if (EFI_ERROR(Status)) {\r
+    goto Done;\r
+  }\r
 \r
   if (ResultBufSize > sizeof(Res)) {\r
     DEBUG ((EFI_D_ERROR, "Tpm2PcrAllocate: Failed ExecuteCommand: Buffer Too Small\r\n"));\r
-    return EFI_BUFFER_TOO_SMALL;\r
+    Status = EFI_BUFFER_TOO_SMALL;\r
+    goto Done;\r
   }\r
 \r
   //\r
@@ -502,7 +506,8 @@ Tpm2PcrAllocate (
   RespSize = SwapBytes32(Res.Header.paramSize);\r
   if (RespSize > sizeof(Res)) {\r
     DEBUG ((EFI_D_ERROR, "Tpm2PcrAllocate: Response size too large! %d\r\n", RespSize));\r
-    return EFI_BUFFER_TOO_SMALL;\r
+    Status = EFI_BUFFER_TOO_SMALL;\r
+    goto Done;\r
   }\r
 \r
   //\r
@@ -510,7 +515,8 @@ Tpm2PcrAllocate (
   //\r
   if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {\r
     DEBUG((EFI_D_ERROR,"Tpm2PcrAllocate: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));\r
-    return EFI_DEVICE_ERROR;\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto Done;\r
   }\r
 \r
   //\r
@@ -521,5 +527,11 @@ Tpm2PcrAllocate (
   *SizeNeeded = SwapBytes32(Res.SizeNeeded);\r
   *SizeAvailable = SwapBytes32(Res.SizeAvailable);\r
 \r
-  return EFI_SUCCESS;\r
+Done:\r
+  //\r
+  // Clear AuthSession Content\r
+  //\r
+  ZeroMem (&Cmd, sizeof(Cmd));\r
+  ZeroMem (&Res, sizeof(Res));\r
+  return Status;\r
 }\r