Refine the server name compare logic

Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
This commit is contained in:
Xiaokang Qian 2022-10-11 09:05:11 +00:00
parent a3b451f950
commit d7adc374d3

View file

@ -876,19 +876,11 @@ static int ssl_prepare_client_hello( mbedtls_ssl_context *ssl )
if( ssl->tls_version == MBEDTLS_SSL_VERSION_TLS1_3 &&
ssl->handshake->resume )
{
int hostname_mismatch = 0;
if( ssl->session_negotiate->hostname != NULL )
{
if( ssl->hostname != NULL )
{
if( strcmp( ssl->hostname, ssl->session_negotiate->hostname) )
hostname_mismatch = 1;
}
else
hostname_mismatch = 1;
}
else
hostname_mismatch = ssl->hostname != NULL;
int hostname_mismatch = ssl->hostname != NULL ||
ssl->session_negotiate->hostname != NULL;
if( ssl->hostname != NULL && ssl->session_negotiate->hostname != NULL )
hostname_mismatch = strcmp(
ssl->hostname, ssl->session_negotiate->hostname ) != 0;
if( hostname_mismatch )
{