Merge pull request #3088 from AndrzejKurek/ssl-mocks-coverity

test_suite_ssl: fix coverity issues with uninitialized members
This commit is contained in:
Jaeden Amero 2020-03-09 19:14:47 +04:00 committed by GitHub
commit 55727c33eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -552,6 +552,13 @@ typedef struct mbedtls_test_message_socket_context
mbedtls_mock_socket* socket; mbedtls_mock_socket* socket;
} mbedtls_test_message_socket_context; } mbedtls_test_message_socket_context;
void mbedtls_message_socket_init( mbedtls_test_message_socket_context *ctx )
{
ctx->queue_input = NULL;
ctx->queue_output = NULL;
ctx->socket = NULL;
}
/* /*
* Setup a given mesasge socket context including initialization of * Setup a given mesasge socket context including initialization of
* input/output queues to a chosen capacity of messages. Also set the * input/output queues to a chosen capacity of messages. Also set the
@ -1652,6 +1659,8 @@ void perform_handshake( handshake_test_options* options )
mbedtls_test_message_queue server_queue, client_queue; mbedtls_test_message_queue server_queue, client_queue;
mbedtls_test_message_socket_context server_context, client_context; mbedtls_test_message_socket_context server_context, client_context;
mbedtls_message_socket_init( &server_context );
mbedtls_message_socket_init( &client_context );
/* Client side */ /* Client side */
if( options->dtls != 0 ) if( options->dtls != 0 )
@ -2503,6 +2512,8 @@ void ssl_message_mock_uninitialized( )
mbedtls_mock_socket client, server; mbedtls_mock_socket client, server;
mbedtls_test_message_queue server_queue, client_queue; mbedtls_test_message_queue server_queue, client_queue;
mbedtls_test_message_socket_context server_context, client_context; mbedtls_test_message_socket_context server_context, client_context;
mbedtls_message_socket_init( &server_context );
mbedtls_message_socket_init( &client_context );
/* Send with a NULL context */ /* Send with a NULL context */
TEST_ASSERT( mbedtls_mock_tcp_send_msg( NULL, message, MSGLEN ) TEST_ASSERT( mbedtls_mock_tcp_send_msg( NULL, message, MSGLEN )
@ -2548,6 +2559,8 @@ void ssl_message_mock_basic( )
unsigned i; unsigned i;
mbedtls_test_message_queue server_queue, client_queue; mbedtls_test_message_queue server_queue, client_queue;
mbedtls_test_message_socket_context server_context, client_context; mbedtls_test_message_socket_context server_context, client_context;
mbedtls_message_socket_init( &server_context );
mbedtls_message_socket_init( &client_context );
TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 1, TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 1,
&server, &server,
@ -2601,6 +2614,8 @@ void ssl_message_mock_queue_overflow_underflow( )
unsigned i; unsigned i;
mbedtls_test_message_queue server_queue, client_queue; mbedtls_test_message_queue server_queue, client_queue;
mbedtls_test_message_socket_context server_context, client_context; mbedtls_test_message_socket_context server_context, client_context;
mbedtls_message_socket_init( &server_context );
mbedtls_message_socket_init( &client_context );
TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 2, TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 2,
&server, &server,
@ -2657,6 +2672,8 @@ void ssl_message_mock_socket_overflow( )
unsigned i; unsigned i;
mbedtls_test_message_queue server_queue, client_queue; mbedtls_test_message_queue server_queue, client_queue;
mbedtls_test_message_socket_context server_context, client_context; mbedtls_test_message_socket_context server_context, client_context;
mbedtls_message_socket_init( &server_context );
mbedtls_message_socket_init( &client_context );
TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 2, TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 2,
&server, &server,
@ -2704,6 +2721,8 @@ void ssl_message_mock_truncated( )
unsigned i; unsigned i;
mbedtls_test_message_queue server_queue, client_queue; mbedtls_test_message_queue server_queue, client_queue;
mbedtls_test_message_socket_context server_context, client_context; mbedtls_test_message_socket_context server_context, client_context;
mbedtls_message_socket_init( &server_context );
mbedtls_message_socket_init( &client_context );
TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 2, TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 2,
&server, &server,
@ -2761,6 +2780,8 @@ void ssl_message_mock_socket_read_error( )
unsigned i; unsigned i;
mbedtls_test_message_queue server_queue, client_queue; mbedtls_test_message_queue server_queue, client_queue;
mbedtls_test_message_socket_context server_context, client_context; mbedtls_test_message_socket_context server_context, client_context;
mbedtls_message_socket_init( &server_context );
mbedtls_message_socket_init( &client_context );
TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 1, TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 1,
&server, &server,
@ -2813,6 +2834,8 @@ void ssl_message_mock_interleaved_one_way( )
unsigned i; unsigned i;
mbedtls_test_message_queue server_queue, client_queue; mbedtls_test_message_queue server_queue, client_queue;
mbedtls_test_message_socket_context server_context, client_context; mbedtls_test_message_socket_context server_context, client_context;
mbedtls_message_socket_init( &server_context );
mbedtls_message_socket_init( &client_context );
TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 3, TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 3,
&server, &server,
@ -2871,6 +2894,8 @@ void ssl_message_mock_interleaved_two_ways( )
unsigned i; unsigned i;
mbedtls_test_message_queue server_queue, client_queue; mbedtls_test_message_queue server_queue, client_queue;
mbedtls_test_message_socket_context server_context, client_context; mbedtls_test_message_socket_context server_context, client_context;
mbedtls_message_socket_init( &server_context );
mbedtls_message_socket_init( &client_context );
TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 3, TEST_ASSERT( mbedtls_message_socket_setup( &server_queue, &client_queue, 3,
&server, &server,