/** @file\r
Implement TPM2 Capability related command.\r
\r
-Copyright (c) 2013 - 2016, 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
return EFI_DEVICE_ERROR;\r
}\r
\r
+ //\r
+ // Fail if command failed\r
+ //\r
+ if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {\r
+ DEBUG ((EFI_D_ERROR, "Tpm2GetCapability: Response Code error! 0x%08x\r\n", SwapBytes32(RecvBuffer.Header.responseCode)));\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
//\r
// Return the response\r
//\r
CopyMem (AlgList, &TpmCap.data.algorithms, sizeof (TPML_ALG_PROPERTY));\r
\r
AlgList->count = SwapBytes32 (AlgList->count);\r
+ if (AlgList->count > MAX_CAP_ALGS) {\r
+ DEBUG ((DEBUG_ERROR, "Tpm2GetCapabilitySupportedAlg - AlgList->count error %x\n", AlgList->count));\r
+ return EFI_DEVICE_ERROR; \r
+ }\r
+\r
for (Index = 0; Index < AlgList->count; Index++) {\r
AlgList->algProperties[Index].alg = SwapBytes16 (AlgList->algProperties[Index].alg);\r
WriteUnaligned32 ((UINT32 *)&AlgList->algProperties[Index].algProperties, SwapBytes32 (ReadUnaligned32 ((UINT32 *)&AlgList->algProperties[Index].algProperties)));\r
}\r
\r
Pcrs->count = SwapBytes32 (TpmCap.data.assignedPCR.count);\r
+ if (Pcrs->count > HASH_COUNT) {\r
+ DEBUG ((DEBUG_ERROR, "Tpm2GetCapabilityPcrs - Pcrs->count error %x\n", Pcrs->count));\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
for (Index = 0; Index < Pcrs->count; Index++) {\r
Pcrs->pcrSelections[Index].hash = SwapBytes16 (TpmCap.data.assignedPCR.pcrSelections[Index].hash);\r
Pcrs->pcrSelections[Index].sizeofSelect = TpmCap.data.assignedPCR.pcrSelections[Index].sizeofSelect;\r
+ if (Pcrs->pcrSelections[Index].sizeofSelect > PCR_SELECT_MAX) {\r
+ DEBUG ((DEBUG_ERROR, "Tpm2GetCapabilityPcrs - sizeofSelect error %x\n", Pcrs->pcrSelections[Index].sizeofSelect));\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
CopyMem (Pcrs->pcrSelections[Index].pcrSelect, TpmCap.data.assignedPCR.pcrSelections[Index].pcrSelect, Pcrs->pcrSelections[Index].sizeofSelect);\r
}\r
\r