Skip to content

Commit

Permalink
Merge pull request #9723 from paul-elliott-arm/fix_new_coverity_issue…
Browse files Browse the repository at this point in the history
…s_3.6

[Backport 3.6] Fix new coverity issues
  • Loading branch information
davidhorstmann-arm authored Oct 25, 2024
2 parents aea9bae + 09a8f4d commit d37d70a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tests/src/bignum_codepath_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#if defined(MBEDTLS_TEST_HOOKS) && !defined(MBEDTLS_THREADING_C)
int mbedtls_codepath_check = MBEDTLS_MPI_IS_TEST;

void mbedtls_codepath_take_safe(void)
static void mbedtls_codepath_take_safe(void)
{
if (mbedtls_codepath_check == MBEDTLS_MPI_IS_TEST) {
mbedtls_codepath_check = MBEDTLS_MPI_IS_SECRET;
}
}

void mbedtls_codepath_take_unsafe(void)
static void mbedtls_codepath_take_unsafe(void)
{
mbedtls_codepath_check = MBEDTLS_MPI_IS_PUBLIC;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/suites/test_suite_ctr_drbg.function
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,14 @@ void ctr_drbg_threads(data_t *expected_result, int reseed, int arg_thread_count)
* as this was the value used when the expected answers were calculated. */
const size_t entropy_len = 48;

mbedtls_ctr_drbg_context ctx;
mbedtls_ctr_drbg_init(&ctx);

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_offset_idx = 0;

/* Need to set a non-default fixed entropy len, to ensure same output across
Expand Down
7 changes: 5 additions & 2 deletions tests/suites/test_suite_psa_crypto_memory.function
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ void local_input_alloc(int input_len, psa_status_t exp_status)

exit:
mbedtls_free(local_input.buffer);
mbedtls_free(input);

if (local_input.buffer != input) {
mbedtls_free(input);
}
}
/* END_CASE */

Expand Down Expand Up @@ -243,7 +246,7 @@ void local_output_round_trip()
TEST_CALLOC(buffer_copy_for_comparison, local_output.length);
memcpy(buffer_copy_for_comparison, local_output.buffer, local_output.length);

psa_crypto_local_output_free(&local_output);
TEST_EQUAL(psa_crypto_local_output_free(&local_output), PSA_SUCCESS);
TEST_ASSERT(local_output.buffer == NULL);
TEST_EQUAL(local_output.length, 0);

Expand Down
7 changes: 5 additions & 2 deletions tests/suites/test_suite_x509write.function
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,24 @@ void x509_csr_check_opaque(char *key_file, int md_type, int key_usage,
int cert_type)
{
mbedtls_pk_context key;
mbedtls_pk_init(&key);

mbedtls_svc_key_id_t key_id = MBEDTLS_SVC_KEY_ID_INIT;
psa_key_attributes_t key_attr = PSA_KEY_ATTRIBUTES_INIT;

mbedtls_x509write_csr req;
mbedtls_x509write_csr_init(&req);

unsigned char buf[4096];
int ret;
size_t pem_len = 0;
const char *subject_name = "C=NL,O=PolarSSL,CN=PolarSSL Server 1";
mbedtls_test_rnd_pseudo_info rnd_info;

mbedtls_x509write_csr_init(&req);
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);

Expand Down

0 comments on commit d37d70a

Please sign in to comment.