mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-16 04:20:49 +00:00
Fix unintentional direct use of memcpy()
Change psa_crypto_output_copy_free() to use psa_crypto_copy_output() rather than calling memcpy directly as was erroneously done previously. Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
parent
0a57ed25c4
commit
c335a4e186
@ -8536,6 +8536,8 @@ psa_status_t psa_crypto_output_copy_alloc(uint8_t *output, size_t output_len,
|
||||
|
||||
psa_status_t psa_crypto_output_copy_free(psa_crypto_output_copy_t *output_copy)
|
||||
{
|
||||
psa_status_t status;
|
||||
|
||||
if (output_copy->buffer == NULL) {
|
||||
output_copy->len = 0;
|
||||
return PSA_SUCCESS;
|
||||
@ -8545,7 +8547,11 @@ psa_status_t psa_crypto_output_copy_free(psa_crypto_output_copy_t *output_copy)
|
||||
return PSA_ERROR_CORRUPTION_DETECTED;
|
||||
}
|
||||
|
||||
memcpy(output_copy->original, output_copy->buffer, output_copy->len);
|
||||
status = psa_crypto_copy_output(output_copy->buffer, output_copy->len,
|
||||
output_copy->original, output_copy->len);
|
||||
if (status != PSA_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
mbedtls_free(output_copy->buffer);
|
||||
output_copy->buffer = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user