/** @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
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
&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
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
//\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
*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