Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.28] Fix new coverity issues #9729

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 5 additions & 3 deletions tests/suites/test_suite_x509write.function
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down