From 1f10d7643ffe3fc86b7a8496207ad6581778eca0 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Fri, 26 Apr 2019 13:34:37 +0100 Subject: [PATCH] Fix uninitialized variable access in debug output of record enc/dec --- library/ssl_tls.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 7c9007790..da42ed7ae 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -1965,6 +1965,8 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } + ssl_extract_add_data_from_record( add_data, rec ); + MBEDTLS_SSL_DEBUG_BUF( 4, "IV used (internal)", iv, transform->ivlen ); MBEDTLS_SSL_DEBUG_BUF( 4, "IV used (transmitted)", @@ -1979,7 +1981,6 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl, * Encrypt and authenticate */ - ssl_extract_add_data_from_record( add_data, rec ); if( ( ret = mbedtls_cipher_auth_encrypt( &transform->cipher_ctx_enc, iv, transform->ivlen, add_data, 13, /* add data */ @@ -2118,12 +2119,12 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); } + ssl_extract_add_data_from_record( add_data, rec ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "using encrypt then mac" ) ); MBEDTLS_SSL_DEBUG_BUF( 4, "MAC'd meta-data", add_data, sizeof( add_data ) ); - ssl_extract_add_data_from_record( add_data, rec ); - mbedtls_md_hmac_update( &transform->md_ctx_enc, add_data, sizeof( add_data ) ); mbedtls_md_hmac_update( &transform->md_ctx_enc,