Add checks for buffer size
Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c
index ed43085..4d5bf20 100644
--- a/library/psa_crypto_cipher.c
+++ b/library/psa_crypto_cipher.c
@@ -532,6 +532,12 @@
if( status != PSA_SUCCESS )
goto exit;
+ if( output_size < accumulated_length )
+ {
+ status = PSA_ERROR_BUFFER_TOO_SMALL;
+ goto exit;
+ }
+
status = cipher_finish( &operation, output + accumulated_length,
output_size - accumulated_length, &olength );
accumulated_length += olength;