Skip to content

Commit

Permalink
Merge pull request #9729 from paul-elliott-arm/fix_new_coverity_issue…
Browse files Browse the repository at this point in the history
…s_2.28

[Backport 2.28] Fix new coverity issues
gilles-peskine-arm authored Oct 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 0f2c45a + 417b8d9 commit 89a87b5
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions tests/suites/test_suite_psa_crypto_memory.function
Original file line number Diff line number Diff line change
@@ -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 */

@@ -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);

8 changes: 5 additions & 3 deletions tests/suites/test_suite_x509write.function
Original file line number Diff line number Diff line change
@@ -207,25 +207,27 @@ 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_algorithm_t md_alg_psa;

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;

memset(&rnd_info, 0x2a, sizeof(mbedtls_test_rnd_pseudo_info));

mbedtls_x509write_csr_init(&req);

USE_PSA_INIT();

md_alg_psa = mbedtls_psa_translate_md((mbedtls_md_type_t) md_type);
TEST_ASSERT(md_alg_psa != MBEDTLS_MD_NONE);

mbedtls_pk_init(&key);
TEST_ASSERT(mbedtls_pk_parse_keyfile(&key, key_file, NULL) == 0);
TEST_ASSERT(mbedtls_pk_wrap_as_opaque(&key, &key_id, md_alg_psa) == 0);

0 comments on commit 89a87b5

Please sign in to comment.