From 7864090ec1ac5ebcdb76db39f324a0faf8e4cf18 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 13 Aug 2018 16:35:15 +0100 Subject: [PATCH] Reset session_in/out pointers in ssl_session_reset_int() Fixes #1941. --- library/ssl_tls.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 91f96c8ab..3b047fc0b 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5973,6 +5973,9 @@ static int ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) ssl->transform_in = NULL; ssl->transform_out = NULL; + ssl->session_in = NULL; + ssl->session_out = NULL; + memset( ssl->out_buf, 0, MBEDTLS_SSL_OUT_BUFFER_LEN ); if( partial == 0 ) memset( ssl->in_buf, 0, MBEDTLS_SSL_IN_BUFFER_LEN ); @@ -6842,14 +6845,14 @@ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl ) size_t transform_expansion; const mbedtls_ssl_transform *transform = ssl->transform_out; + if( transform == NULL ) + return( (int) mbedtls_ssl_hdr_len( ssl ) ); + #if defined(MBEDTLS_ZLIB_SUPPORT) if( ssl->session_out->compression != MBEDTLS_SSL_COMPRESS_NULL ) return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); #endif - if( transform == NULL ) - return( (int) mbedtls_ssl_hdr_len( ssl ) ); - switch( mbedtls_cipher_get_cipher_mode( &transform->cipher_ctx_enc ) ) { case MBEDTLS_MODE_GCM: