MeasuredBoot: Fix client API
The boundary check of the input params was wrong in
`tfm_measured_boot_extend_measurement()`.
Change-Id: I366c6b5d717284059a478e4bb6434b9b4f2a85ca
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
diff --git a/partitions/measured_boot/interface/src/measured_boot_api.c b/partitions/measured_boot/interface/src/measured_boot_api.c
index c35b8d1..8ef5c00 100644
--- a/partitions/measured_boot/interface/src/measured_boot_api.c
+++ b/partitions/measured_boot/interface/src/measured_boot_api.c
@@ -86,8 +86,13 @@
.sw_type = {0},
.sw_type_size = sw_type_size,
};
- if (sw_type_size > 0 && sw_type[sw_type_size - 1] == '\0') {
- extend_iov.sw_type_size--;
+
+ if (version_size > VERSION_MAX_SIZE) {
+ return PSA_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (version_size > 0 && version[version_size - 1] == '\0') {
+ version_size--;
}
psa_invec in_vec[] = {
@@ -97,14 +102,14 @@
{.base = version, .len = version_size},
{.base = measurement_value, .len = measurement_value_size}
};
- if (version_size > 0 && version[version_size - 1] == '\0') {
- in_vec[2].len--;
- }
if (sw_type != NULL) {
if (extend_iov.sw_type_size > SW_TYPE_MAX_SIZE) {
return PSA_ERROR_INVALID_ARGUMENT;
}
+ if (sw_type_size > 0 && sw_type[sw_type_size - 1] == '\0') {
+ extend_iov.sw_type_size--;
+ }
memcpy(extend_iov.sw_type, sw_type, extend_iov.sw_type_size);
}