Fix tests where tests were done prior to init

Variables that are in any way destructed on exit should be initialised
prior to any tests that might jump to exit, to save potential
uninitialised memory accesses.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2024-10-24 14:27:26 +01:00
parent 202b69c2b6
commit 7c6686014b
2 changed files with 5 additions and 4 deletions

View File

@ -298,11 +298,12 @@ void x509_csr_check_opaque(char *key_file, int md_type, int key_usage,
mbedtls_test_rnd_pseudo_info rnd_info;
mbedtls_x509write_csr_init(&req);
mbedtls_pk_init(&key);
MD_OR_USE_PSA_INIT();
memset(&rnd_info, 0x2a, sizeof(mbedtls_test_rnd_pseudo_info));
mbedtls_pk_init(&key);
TEST_ASSERT(mbedtls_pk_parse_keyfile(&key, key_file, NULL,
mbedtls_test_rnd_std_rand, NULL) == 0);

View File

@ -365,12 +365,12 @@ void ctr_drbg_threads(data_t *expected_result, int reseed, int arg_thread_count)
AES_PSA_INIT();
TEST_CALLOC(threads, sizeof(mbedtls_test_thread_t) * thread_count);
memset(out, 0, sizeof(out));
mbedtls_ctr_drbg_context ctx;
mbedtls_ctr_drbg_init(&ctx);
TEST_CALLOC(threads, sizeof(mbedtls_test_thread_t) * thread_count);
memset(out, 0, sizeof(out));
test_offset_idx = 0;
/* Need to set a non-default fixed entropy len, to ensure same output across