mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Fix missing initializations on some error paths
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -31,15 +31,13 @@ static void ctr_drbg_validate_internal(int reseed_mode, data_t *nonce,
|
||||
data_t *result)
|
||||
{
|
||||
mbedtls_ctr_drbg_context ctx;
|
||||
mbedtls_ctr_drbg_init(&ctx);
|
||||
unsigned char buf[64];
|
||||
|
||||
size_t entropy_chunk_len = (size_t) entropy_len_arg;
|
||||
|
||||
TEST_ASSERT(entropy_chunk_len <= sizeof(buf));
|
||||
|
||||
test_offset_idx = 0;
|
||||
mbedtls_ctr_drbg_init(&ctx);
|
||||
|
||||
test_max_idx = entropy->len;
|
||||
|
||||
/* CTR_DRBG_Instantiate(entropy[:entropy->len], nonce, perso, <ignored>)
|
||||
|
@ -31,13 +31,13 @@ static void fix_new_lines(unsigned char *in_str, size_t *len)
|
||||
static void pk_write_check_common(char *key_file, int is_public_key, int is_der)
|
||||
{
|
||||
mbedtls_pk_context key;
|
||||
mbedtls_pk_init(&key);
|
||||
unsigned char *buf = NULL;
|
||||
unsigned char *check_buf = NULL;
|
||||
unsigned char *start_buf;
|
||||
size_t buf_len, check_buf_len;
|
||||
int ret;
|
||||
|
||||
mbedtls_pk_init(&key);
|
||||
USE_PSA_INIT();
|
||||
|
||||
/* Note: if mbedtls_pk_load_file() successfully reads the file, then
|
||||
|
@ -1290,7 +1290,7 @@ void sign_verify(int flow,
|
||||
mbedtls_svc_key_id_t returned_id;
|
||||
mbedtls_svc_key_id_t sw_key = MBEDTLS_SVC_KEY_ID_INIT;
|
||||
psa_key_attributes_t sw_attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
psa_key_attributes_t drv_attributes;
|
||||
psa_key_attributes_t drv_attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
uint8_t signature[PSA_SIGNATURE_MAX_SIZE];
|
||||
size_t signature_length;
|
||||
|
||||
|
@ -19,6 +19,7 @@ void test_callback_buffer_sanity()
|
||||
{
|
||||
enum { MSGLEN = 10 };
|
||||
mbedtls_test_ssl_buffer buf;
|
||||
mbedtls_test_ssl_buffer_init(&buf);
|
||||
unsigned char input[MSGLEN];
|
||||
unsigned char output[MSGLEN];
|
||||
|
||||
@ -38,8 +39,6 @@ void test_callback_buffer_sanity()
|
||||
|
||||
/* Make sure calling put and get on a buffer that hasn't been set up results
|
||||
* in error. */
|
||||
mbedtls_test_ssl_buffer_init(&buf);
|
||||
|
||||
TEST_ASSERT(mbedtls_test_ssl_buffer_put(&buf, input, sizeof(input))
|
||||
== -1);
|
||||
TEST_ASSERT(mbedtls_test_ssl_buffer_get(&buf, output, sizeof(output))
|
||||
|
@ -457,16 +457,16 @@ void mbedtls_x509_string_to_names(char *name, char *parsed_name, int result
|
||||
int ret;
|
||||
size_t len = 0;
|
||||
mbedtls_asn1_named_data *names = NULL;
|
||||
mbedtls_x509_name parsed, *parsed_cur, *parsed_prv;
|
||||
unsigned char buf[1024], out[1024], *c;
|
||||
mbedtls_x509_name parsed;
|
||||
memset(&parsed, 0, sizeof(parsed));
|
||||
mbedtls_x509_name *parsed_cur = NULL;
|
||||
mbedtls_x509_name *parsed_prv = NULL;
|
||||
unsigned char buf[1024] = { 0 };
|
||||
unsigned char out[1024] = { 0 };
|
||||
unsigned char *c = buf + sizeof(buf);
|
||||
|
||||
USE_PSA_INIT();
|
||||
|
||||
memset(&parsed, 0, sizeof(parsed));
|
||||
memset(out, 0, sizeof(out));
|
||||
memset(buf, 0, sizeof(buf));
|
||||
c = buf + sizeof(buf);
|
||||
|
||||
ret = mbedtls_x509_string_to_names(&names, name);
|
||||
TEST_ASSERT(ret == result);
|
||||
|
||||
|
Reference in New Issue
Block a user