mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
Merge pull request #9721 from paul-elliott-arm/fix_new_coverity_issues
Fix new coverity issues
This commit is contained in:
commit
f8d13d8fad
@ -11,14 +11,14 @@
|
|||||||
#if defined(MBEDTLS_TEST_HOOKS) && !defined(MBEDTLS_THREADING_C)
|
#if defined(MBEDTLS_TEST_HOOKS) && !defined(MBEDTLS_THREADING_C)
|
||||||
int mbedtls_codepath_check = MBEDTLS_MPI_IS_TEST;
|
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) {
|
if (mbedtls_codepath_check == MBEDTLS_MPI_IS_TEST) {
|
||||||
mbedtls_codepath_check = MBEDTLS_MPI_IS_SECRET;
|
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;
|
mbedtls_codepath_check = MBEDTLS_MPI_IS_PUBLIC;
|
||||||
}
|
}
|
||||||
|
@ -288,21 +288,24 @@ void x509_csr_check_opaque(char *key_file, int md_type, int key_usage,
|
|||||||
int cert_type)
|
int cert_type)
|
||||||
{
|
{
|
||||||
mbedtls_pk_context key;
|
mbedtls_pk_context key;
|
||||||
|
mbedtls_pk_init(&key);
|
||||||
|
|
||||||
mbedtls_svc_key_id_t key_id = MBEDTLS_SVC_KEY_ID_INIT;
|
mbedtls_svc_key_id_t key_id = MBEDTLS_SVC_KEY_ID_INIT;
|
||||||
psa_key_attributes_t key_attr = PSA_KEY_ATTRIBUTES_INIT;
|
psa_key_attributes_t key_attr = PSA_KEY_ATTRIBUTES_INIT;
|
||||||
|
|
||||||
mbedtls_x509write_csr req;
|
mbedtls_x509write_csr req;
|
||||||
|
mbedtls_x509write_csr_init(&req);
|
||||||
|
|
||||||
unsigned char buf[4096];
|
unsigned char buf[4096];
|
||||||
int ret;
|
int ret;
|
||||||
size_t pem_len = 0;
|
size_t pem_len = 0;
|
||||||
const char *subject_name = "C=NL,O=PolarSSL,CN=PolarSSL Server 1";
|
const char *subject_name = "C=NL,O=PolarSSL,CN=PolarSSL Server 1";
|
||||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||||
|
|
||||||
mbedtls_x509write_csr_init(&req);
|
|
||||||
MD_OR_USE_PSA_INIT();
|
MD_OR_USE_PSA_INIT();
|
||||||
|
|
||||||
memset(&rnd_info, 0x2a, sizeof(mbedtls_test_rnd_pseudo_info));
|
memset(&rnd_info, 0x2a, sizeof(mbedtls_test_rnd_pseudo_info));
|
||||||
|
|
||||||
mbedtls_pk_init(&key);
|
|
||||||
TEST_ASSERT(mbedtls_pk_parse_keyfile(&key, key_file, NULL,
|
TEST_ASSERT(mbedtls_pk_parse_keyfile(&key, key_file, NULL,
|
||||||
mbedtls_test_rnd_std_rand, NULL) == 0);
|
mbedtls_test_rnd_std_rand, NULL) == 0);
|
||||||
|
|
||||||
|
@ -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. */
|
* as this was the value used when the expected answers were calculated. */
|
||||||
const size_t entropy_len = 48;
|
const size_t entropy_len = 48;
|
||||||
|
|
||||||
|
mbedtls_ctr_drbg_context ctx;
|
||||||
|
mbedtls_ctr_drbg_init(&ctx);
|
||||||
|
|
||||||
AES_PSA_INIT();
|
AES_PSA_INIT();
|
||||||
|
|
||||||
TEST_CALLOC(threads, sizeof(mbedtls_test_thread_t) * thread_count);
|
TEST_CALLOC(threads, sizeof(mbedtls_test_thread_t) * thread_count);
|
||||||
memset(out, 0, sizeof(out));
|
memset(out, 0, sizeof(out));
|
||||||
|
|
||||||
mbedtls_ctr_drbg_context ctx;
|
|
||||||
mbedtls_ctr_drbg_init(&ctx);
|
|
||||||
|
|
||||||
test_offset_idx = 0;
|
test_offset_idx = 0;
|
||||||
|
|
||||||
/* Need to set a non-default fixed entropy len, to ensure same output across
|
/* Need to set a non-default fixed entropy len, to ensure same output across
|
||||||
|
@ -107,7 +107,10 @@ void local_input_alloc(int input_len, psa_status_t exp_status)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_free(local_input.buffer);
|
mbedtls_free(local_input.buffer);
|
||||||
|
|
||||||
|
if (local_input.buffer != input) {
|
||||||
mbedtls_free(input);
|
mbedtls_free(input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -243,7 +246,7 @@ void local_output_round_trip()
|
|||||||
TEST_CALLOC(buffer_copy_for_comparison, local_output.length);
|
TEST_CALLOC(buffer_copy_for_comparison, local_output.length);
|
||||||
memcpy(buffer_copy_for_comparison, local_output.buffer, 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_ASSERT(local_output.buffer == NULL);
|
||||||
TEST_EQUAL(local_output.length, 0);
|
TEST_EQUAL(local_output.length, 0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user