From e0c5df50be5d599e0edd08ce614ceaec30d732dc Mon Sep 17 00:00:00 2001 From: Moran Peker Date: Mon, 18 Feb 2019 15:21:53 +0200 Subject: [PATCH] Attestation: Add parameter and entry size checks --- .../COMPONENT_PSA_SRV_IMPL/attest_boot_status_loader.c | 3 +++ .../COMPONENT_PSA_SRV_IMPL/psa_attestation_stubs.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_boot_status_loader.c b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_boot_status_loader.c index 06505041f9..3acb8ad26c 100755 --- a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_boot_status_loader.c +++ b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_boot_status_loader.c @@ -82,6 +82,9 @@ attest_get_boot_data(uint8_t major_type, void *ptr, uint32_t len) { return PSA_ATTEST_ERR_INIT_FAILED; } } + if (tlv_entry->tlv_len == 0) { + break; + } } shared_data_init_done = SHARED_DATA_INITIALZED; diff --git a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/psa_attestation_stubs.c b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/psa_attestation_stubs.c index 77288801ce..47d05fc65e 100755 --- a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/psa_attestation_stubs.c +++ b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/psa_attestation_stubs.c @@ -23,5 +23,9 @@ enum psa_attest_err_t attest_check_memory_access(void *addr, uint32_t size, enum attest_memory_access_t access) { + if (size == 0) + { + return PSA_ATTEST_ERR_INVALID_INPUT; + } return PSA_ATTEST_ERR_SUCCESS; } \ No newline at end of file