From dba460f2f358b9fb0b00157e20ecd9958106870f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 24 Jun 2015 22:59:30 +0200 Subject: [PATCH] Add SSL "assertion" to help static analysis --- library/ssl_cli.c | 3 +-- library/ssl_srv.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 661af12db..0db7c1833 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -2919,7 +2919,7 @@ int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ) { int ret = 0; - if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER ) + if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "client state: %d", ssl->state ) ); @@ -2929,7 +2929,6 @@ int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && - ssl->handshake != NULL && ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) { if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) diff --git a/library/ssl_srv.c b/library/ssl_srv.c index c7fb0abdb..96c73d2ad 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -3580,7 +3580,7 @@ int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ) { int ret = 0; - if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER ) + if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "server state: %d", ssl->state ) ); @@ -3590,7 +3590,6 @@ int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && - ssl->handshake != NULL && ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) { if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 )