Merge 66de3049019e61a155c4aff93a76e1b9825691c2 into 4fdb917aae2fb5876e04f88621630712a906a067

This commit is contained in:
Gilles Peskine 2026-10-27 10:46:03 -04:00 committed by GitHub
commit 0b10208e14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View File

@ -0,0 +1,7 @@
Bugfix
* Fix mbedtls_ssl_set_hostname(ssl, NULL) causing the connection to
fail when compiled with some versions of IAR in configurations
with MBEDTLS_SSL_SERVER_NAME_INDICATION disabled. Also fix
mbedtls_ssl_set_hostname(ssl, "") which could disable hostname
verification instead of requiring an empty hostname when compiled
with some optimizing compilers. Fixes #10842.

View File

@ -2789,7 +2789,7 @@ void mbedtls_ssl_conf_groups(mbedtls_ssl_config *conf,
* mbedtls_ssl_set_hostname() has been called with `NULL`.
* If mbedtls_ssl_set_hostname() has never been called on `ssl`, then
* `ssl->hostname == NULL`. */
static const char *const ssl_hostname_skip_cn_verification = "";
static const char *const ssl_hostname_skip_cn_verification[] = { 0 };
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
/** Whether mbedtls_ssl_set_hostname() has been called.
@ -2820,7 +2820,7 @@ static
#endif
const char *mbedtls_ssl_get_hostname_pointer(const mbedtls_ssl_context *ssl)
{
if (ssl->hostname == ssl_hostname_skip_cn_verification) {
if (ssl->hostname == (char *) ssl_hostname_skip_cn_verification) {
return NULL;
}
return ssl->hostname;
@ -2830,7 +2830,7 @@ const char *mbedtls_ssl_get_hostname_pointer(const mbedtls_ssl_context *ssl)
static void mbedtls_ssl_free_hostname(mbedtls_ssl_context *ssl)
{
if (ssl->hostname != NULL &&
ssl->hostname != ssl_hostname_skip_cn_verification) {
ssl->hostname != (char *) ssl_hostname_skip_cn_verification) {
mbedtls_zeroize_and_free(ssl->hostname, strlen(ssl->hostname));
}
ssl->hostname = NULL;