diff --git a/library/debug.c b/library/debug.c index a032478da..a9cd814be 100644 --- a/library/debug.c +++ b/library/debug.c @@ -86,7 +86,7 @@ void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level, char str[DEBUG_BUF_SIZE]; int ret; - if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold ) + if( NULL == ssl || NULL == ssl->conf || NULL == ssl->conf->f_dbg || level > debug_threshold ) return; va_start( argp, format ); diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 9208ec9c8..80a908d9c 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5773,7 +5773,7 @@ int mbedtls_ssl_set_hs_ecjpake_password( mbedtls_ssl_context *ssl, { mbedtls_ecjpake_role role; - if( ssl->handshake == NULL && ssl->conf == NULL ) + if( ssl->handshake == NULL || ssl->conf == NULL ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER ) diff --git a/programs/aes/crypt_and_hash.c b/programs/aes/crypt_and_hash.c index 102144eca..4af39a542 100644 --- a/programs/aes/crypt_and_hash.c +++ b/programs/aes/crypt_and_hash.c @@ -184,7 +184,12 @@ int main( int argc, char *argv[] ) mbedtls_fprintf( stderr, "Message Digest '%s' not found\n", argv[5] ); goto exit; } - mbedtls_md_setup( &md_ctx, md_info, 1 ); + + if( mbedtls_md_setup( &md_ctx, md_info, 1 ) != 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_md_setup unsuccessful: This shouldn't happen.\n" ); + goto exit; + } /* * Read the secret key and clean the command line. @@ -399,6 +404,18 @@ int main( int argc, char *argv[] ) goto exit; } + /* + * Make coverity happy. + */ + if( mbedtls_cipher_get_block_size( &cipher_ctx ) == 0 ) + { + mbedtls_fprintf( stderr, "mbedtls_cipher_get_block_size returned with 0. This shouldn't happen.\n" ); + goto exit; + } + + /* + * Check the file size. + */ if( ( ( filesize - mbedtls_md_get_size( md_info ) ) % mbedtls_cipher_get_block_size( &cipher_ctx ) ) != 0 ) {