mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Reject zero-lengths in psa_crypto_copy_and_free()
Zero-length buffers should be represented in the psa_crypto_buffer_copy_t struct as NULL if it was created in psa_crypto_alloc_and_copy(), so reject non-NULL zero-length buffers. Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
@ -8521,7 +8521,17 @@ error:
|
||||
|
||||
psa_status_t psa_crypto_copy_and_free(psa_crypto_buffer_copy_t *buffers)
|
||||
{
|
||||
if ((buffers->input != NULL) && (buffers->input_len == 0)) {
|
||||
/* Reject zero-length buffers, these should have been represented by
|
||||
* NULL in psa_crypto_alloc_and_copy() */
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
if (buffers->output != NULL) {
|
||||
if (buffers->output_len == 0) {
|
||||
/* Reject zero-length buffers, these should have been represented
|
||||
* by NULL in psa_crypto_alloc_and_copy() */
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
if (buffers->output_original == NULL) {
|
||||
/* Output is non-NULL but original output is NULL. The argument
|
||||
* buffers is invalid. Return an error as we have no original to
|
||||
|
Reference in New Issue
Block a user