SPM: Update the overflow check for in_num and out_num
in_num > SIZE_MAX - out_num reflects better for overflow check.
Change-Id: I54704d54d777637a6b1a2ec8b743aff4dd873538
Signed-off-by: Summer Qin <summer.qin@arm.com>
diff --git a/secure_fw/spm/ffm/psa_api.c b/secure_fw/spm/ffm/psa_api.c
index a303784..4a5041e 100644
--- a/secure_fw/spm/ffm/psa_api.c
+++ b/secure_fw/spm/ffm/psa_api.c
@@ -163,8 +163,7 @@
}
/* It is a PROGRAMMER ERROR if in_len + out_len > PSA_MAX_IOVEC. */
- if ((in_num > PSA_MAX_IOVEC) ||
- (out_num > PSA_MAX_IOVEC) ||
+ if ((in_num > SIZE_MAX - out_num) ||
(in_num + out_num > PSA_MAX_IOVEC)) {
return PSA_ERROR_PROGRAMMER_ERROR;
}