From 78c4fb45513847b8e08f5a5f84d26a799c6b3d29 Mon Sep 17 00:00:00 2001 From: Gabor Mezei Date: Tue, 20 Dec 2022 18:09:49 +0100 Subject: [PATCH] Fix possible uninitialization error Signed-off-by: Gabor Mezei --- tests/suites/test_suite_bignum_mod.function | 26 ++++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/suites/test_suite_bignum_mod.function b/tests/suites/test_suite_bignum_mod.function index 4914e1d89..527146e30 100644 --- a/tests/suites/test_suite_bignum_mod.function +++ b/tests/suites/test_suite_bignum_mod.function @@ -111,20 +111,20 @@ void mpi_mod_mul( char * input_A, { mbedtls_mpi_uint *X = NULL; + mbedtls_mpi_mod_residue rA = { NULL, 0 }; + mbedtls_mpi_mod_residue rB = { NULL, 0 }; + mbedtls_mpi_mod_residue rR = { NULL, 0 }; + mbedtls_mpi_mod_residue rX = { NULL, 0 }; + mbedtls_mpi_mod_modulus m; mbedtls_mpi_mod_modulus_init( &m ); TEST_EQUAL( test_read_modulus( &m, MBEDTLS_MPI_MOD_REP_MONTGOMERY, input_N ), 0 ); - mbedtls_mpi_mod_residue rA; TEST_EQUAL( test_read_residue( &rA, &m, input_A, 0 ), 0 ); - - mbedtls_mpi_mod_residue rB; TEST_EQUAL( test_read_residue( &rB, &m, input_B, 0 ), 0 ); - - mbedtls_mpi_mod_residue rR; - TEST_EQUAL( test_read_residue( &rR, &m, result, 0 ), 0 ); + TEST_EQUAL( test_read_residue( &rR, &m, result, 0 ), 0 ); const size_t limbs = m.limbs; const size_t bytes = limbs * sizeof( mbedtls_mpi_uint ); @@ -135,7 +135,6 @@ void mpi_mod_mul( char * input_A, ASSERT_ALLOC( X, limbs ); - mbedtls_mpi_mod_residue rX; TEST_EQUAL( mbedtls_mpi_mod_residue_setup( &rX, &m, X, limbs ), 0 ); TEST_EQUAL( mbedtls_mpi_mod_mul( &rX, &rA, &rB, &m ), 0 ); @@ -200,26 +199,25 @@ void mpi_mod_mul_neg( char * input_A, { mbedtls_mpi_uint *X = NULL; + mbedtls_mpi_mod_residue rA = { NULL, 0 }; + mbedtls_mpi_mod_residue rB = { NULL, 0 }; + mbedtls_mpi_mod_residue rR = { NULL, 0 }; + mbedtls_mpi_mod_residue rX = { NULL, 0 }; + mbedtls_mpi_mod_modulus m; mbedtls_mpi_mod_modulus_init( &m ); TEST_EQUAL( test_read_modulus( &m, MBEDTLS_MPI_MOD_REP_MONTGOMERY, input_N ), 0 ); - mbedtls_mpi_mod_residue rA; TEST_EQUAL( test_read_residue( &rA, &m, input_A, 1 ), 0 ); - - mbedtls_mpi_mod_residue rB; TEST_EQUAL( test_read_residue( &rB, &m, input_B, 1 ), 0 ); - - mbedtls_mpi_mod_residue rR; - TEST_EQUAL( test_read_residue( &rR, &m, result, 1 ), 0 ); + TEST_EQUAL( test_read_residue( &rR, &m, result, 1 ), 0 ); const size_t limbs = m.limbs; ASSERT_ALLOC( X, limbs ); - mbedtls_mpi_mod_residue rX; TEST_EQUAL( mbedtls_mpi_mod_residue_setup( &rX, &m, X, limbs ), 0 ); rX.limbs = rR.limbs;