From a7eb81290b178ad74adf27b5ac33060087e050b1 Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Tue, 20 Aug 2024 12:33:42 +0100 Subject: [PATCH] Fix memory corruption in exp_mod tests Signed-off-by: Janos Follath --- tf-psa-crypto/tests/suites/test_suite_bignum_core.function | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tf-psa-crypto/tests/suites/test_suite_bignum_core.function b/tf-psa-crypto/tests/suites/test_suite_bignum_core.function index 39a50520a..3128307b5 100644 --- a/tf-psa-crypto/tests/suites/test_suite_bignum_core.function +++ b/tf-psa-crypto/tests/suites/test_suite_bignum_core.function @@ -1329,7 +1329,7 @@ void mpi_core_exp_mod(char *input_N, char *input_A, /* Check both with output aliased to input */ TEST_CALLOC(A_copy, A_limbs); - memcpy(A_copy, A, sizeof(A_copy) * A_limbs); + memcpy(A_copy, A, sizeof(*A_copy) * A_limbs); TEST_CF_SECRET(A, A_limbs * sizeof(mbedtls_mpi_uint)); TEST_CF_SECRET(N, N_limbs * sizeof(mbedtls_mpi_uint)); @@ -1344,7 +1344,7 @@ void mpi_core_exp_mod(char *input_N, char *input_A, TEST_EQUAL(0, memcmp(X, A, N_limbs * sizeof(mbedtls_mpi_uint))); TEST_CF_PUBLIC(A, A_limbs * sizeof(mbedtls_mpi_uint)); - memcpy(A, A_copy, sizeof(A) * A_limbs); + memcpy(A, A_copy, sizeof(*A) * A_limbs); #if defined(MBEDTLS_TEST_HOOKS) && !defined(MBEDTLS_THREADING_C) mbedtls_mpi_optionally_safe_codepath_reset(); #endif