Skip call to memcpy if buffer length is zero
This allows the copy functions to work when passed a (NULL, 0) buffer.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index e03e2ae..43495e2 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -8462,7 +8462,9 @@
return PSA_ERROR_CORRUPTION_DETECTED;
}
- memcpy(input_copy, input, input_len);
+ if (input_len > 0) {
+ memcpy(input_copy, input, input_len);
+ }
return PSA_SUCCESS;
}
@@ -8486,7 +8488,11 @@
if (output_len < output_copy_len) {
return PSA_ERROR_CORRUPTION_DETECTED;
}
- memcpy(output, output_copy, output_copy_len);
+
+ if (output_copy_len > 0) {
+ memcpy(output, output_copy, output_copy_len);
+ }
+
return PSA_SUCCESS;
}