From 39924684f4d5dca0d9f3756a9e780fce290c9faf Mon Sep 17 00:00:00 2001 From: Yves Lefloch Date: Wed, 22 Mar 2017 17:14:07 +0100 Subject: [PATCH] tee-supplicant: Report error on short buffer when loading TA Change-Id: Ie1a2a514e302d387d063f5a03cabee944fb4765a Signed-off-by: Yves Lefloch Acked-by: Jerome Forissier Reviewed-by: Etienne Carriere Reviewed-by: Jens Wiklander Signed-off-by: Rafal Tyminski --- tee-supplicant/src/tee_supplicant.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tee-supplicant/src/tee_supplicant.c b/tee-supplicant/src/tee_supplicant.c index 9258c47..dc710df 100644 --- a/tee-supplicant/src/tee_supplicant.c +++ b/tee-supplicant/src/tee_supplicant.c @@ -341,6 +341,14 @@ static uint32_t load_ta(size_t num_params, struct tee_ioctl_param *params) } params[1].u.memref.size = size; + + /* + * If a buffer wasn't provided, just tell which size it should be. + * If it was provided but isn't big enough, report an error. + */ + if (shm_ta.buffer && size > shm_ta.size) + return TEEC_ERROR_SHORT_BUFFER; + return TEEC_SUCCESS; } -- 2.34.1