1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-06-25 22:56:35 +08:00

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 && if( ssl->tls_version == MBEDTLS_SSL_VERSION_TLS1_3 &&
ssl->handshake->resume ) ssl->handshake->resume )
{ {
int hostname_mismatch = 0; int hostname_mismatch = ssl->hostname != NULL ||
if( ssl->session_negotiate->hostname != NULL ) ssl->session_negotiate->hostname != NULL;
{ if( ssl->hostname != NULL && ssl->session_negotiate->hostname != NULL )
if( ssl->hostname != NULL ) hostname_mismatch = strcmp(
{ ssl->hostname, ssl->session_negotiate->hostname ) != 0;
if( strcmp( ssl->hostname, ssl->session_negotiate->hostname) )
hostname_mismatch = 1;
}
else
hostname_mismatch = 1;
}
else
hostname_mismatch = ssl->hostname != NULL;
if( hostname_mismatch ) if( hostname_mismatch )
{ {