Check the return status of the functions first

Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
This commit is contained in:
gabor-mezei-arm 2021-06-29 16:42:13 +02:00
parent 58c1727775
commit 6158e283cc
No known key found for this signature in database
GPG key ID: 106F5A41ECC305BD

View file

@ -482,16 +482,17 @@ static psa_status_t cipher_encrypt( const psa_key_attributes_t *attributes,
output + operation.iv_length,
output_size - operation.iv_length,
&olength );
accumulated_length += olength;
if( status != PSA_SUCCESS )
goto exit;
accumulated_length += olength;
status = cipher_finish( &operation, output + accumulated_length,
output_size - accumulated_length, &olength );
accumulated_length += olength;
if( status != PSA_SUCCESS )
goto exit;
accumulated_length += olength;
*output_length = accumulated_length;
exit:
@ -531,17 +532,17 @@ static psa_status_t cipher_decrypt( const psa_key_attributes_t *attributes,
status = cipher_update( &operation, input + operation.iv_length,
input_length - operation.iv_length,
output, output_size, &olength );
accumulated_length = olength;
if( status != PSA_SUCCESS )
goto exit;
accumulated_length = olength;
status = cipher_finish( &operation, output + accumulated_length,
output_size - accumulated_length, &olength );
accumulated_length += olength;
if( status != PSA_SUCCESS )
goto exit;
accumulated_length += olength;
*output_length = accumulated_length;
exit: