Merge remote-tracking branch 'restricted/pr/492' into mbedtls-2.1-restricted

This commit is contained in:
Simon Butcher 2018-08-28 15:23:56 +01:00
commit d22de0aaa7
2 changed files with 33 additions and 4 deletions

View File

@ -2,6 +2,11 @@ mbed TLS ChangeLog (Sorted per branch, date)
= mbed TLS x.x.x branch released xxxx-xx-xx = mbed TLS x.x.x branch released xxxx-xx-xx
Security
* Fix a potential memory leak in mbedtls_ssl_setup( ) function. An allocation
failure could leave an unreleased buffer. A handshake init failure would
lead to leaving two unreleased buffers.
Bugfix Bugfix
* Fixes an issue with MBEDTLS_CHACHAPOLY_C which would not compile if * Fixes an issue with MBEDTLS_CHACHAPOLY_C which would not compile if
MBEDTLS_ARC4_C and MBEDTLS_CIPHER_NULL_CIPHER weren't also defined. #1890 MBEDTLS_ARC4_C and MBEDTLS_CIPHER_NULL_CIPHER weren't also defined. #1890

View File

@ -5634,13 +5634,14 @@ int mbedtls_ssl_setup( mbedtls_ssl_context *ssl,
/* /*
* Prepare base structures * Prepare base structures
*/ */
ssl->in_buf = NULL;
ssl->out_buf = NULL;
if( ( ssl-> in_buf = mbedtls_calloc( 1, len ) ) == NULL || if( ( ssl-> in_buf = mbedtls_calloc( 1, len ) ) == NULL ||
( ssl->out_buf = mbedtls_calloc( 1, len ) ) == NULL ) ( ssl->out_buf = mbedtls_calloc( 1, len ) ) == NULL )
{ {
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", len ) ); MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", len ) );
mbedtls_free( ssl->in_buf ); ret = MBEDTLS_ERR_SSL_ALLOC_FAILED;
ssl->in_buf = NULL; goto error;
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
} }
#if defined(MBEDTLS_SSL_PROTO_DTLS) #if defined(MBEDTLS_SSL_PROTO_DTLS)
@ -5675,9 +5676,32 @@ int mbedtls_ssl_setup( mbedtls_ssl_context *ssl,
} }
if( ( ret = ssl_handshake_init( ssl ) ) != 0 ) if( ( ret = ssl_handshake_init( ssl ) ) != 0 )
return( ret ); goto error;
return( 0 ); return( 0 );
error:
mbedtls_free( ssl->in_buf );
mbedtls_free( ssl->out_buf );
ssl->conf = NULL;
ssl->in_buf = NULL;
ssl->out_buf = NULL;
ssl->in_hdr = NULL;
ssl->in_ctr = NULL;
ssl->in_len = NULL;
ssl->in_iv = NULL;
ssl->in_msg = NULL;
ssl->out_hdr = NULL;
ssl->out_ctr = NULL;
ssl->out_len = NULL;
ssl->out_iv = NULL;
ssl->out_msg = NULL;
return( ret );
} }
/* /*