1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Reject NULL original_output with non-NULL output

If we have a copy buffer but no original to copy back to, there is not
much sensible we can do. The psa_crypto_buffer_copy_t state is invalid.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann
2023-11-01 17:55:43 +00:00
parent 5847b70829
commit 0368d20d51
2 changed files with 12 additions and 0 deletions

View File

@ -5603,6 +5603,12 @@ error:
psa_status_t psa_crypto_copy_and_free(psa_crypto_buffer_copy_t *buffers)
{
if (buffers->output != NULL) {
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
* copy back to. */
return PSA_ERROR_INVALID_ARGUMENT;
}
memcpy(buffers->output_original, buffers->output, buffers->output_len);
}