Fix heap use-after-free corruption issue

Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
This commit is contained in:
Xiaokang Qian 2022-10-12 14:30:27 +00:00
parent 307a7303fd
commit 997669aeeb

View file

@ -258,9 +258,12 @@ int mbedtls_ssl_session_copy( mbedtls_ssl_session *dst,
defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
if( src->endpoint == MBEDTLS_SSL_IS_CLIENT ) if( src->endpoint == MBEDTLS_SSL_IS_CLIENT )
{ {
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
dst->hostname = NULL; dst->hostname = NULL;
return mbedtls_ssl_session_set_hostname( dst, ret = mbedtls_ssl_session_set_hostname( dst,
src->hostname ); src->hostname );
if( ret != 0)
return ret;
} }
#endif /* MBEDTLS_SSL_PROTO_TLS1_3 && MBEDTLS_SSL_SERVER_NAME_INDICATION */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3 && MBEDTLS_SSL_SERVER_NAME_INDICATION */
#endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */ #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */