From 7306f543df2005e5bd489e0e0ada8d3f8742fe4d Mon Sep 17 00:00:00 2001 From: Ashish Sharma Date: Tue, 30 Jun 2026 14:26:19 +0800 Subject: [PATCH] fix(esp-tls): guard against NULL PSK hint to prevent crash --- components/esp-tls/esp_tls_mbedtls.c | 6 +++++- components/esp-tls/test_apps/README.md | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/esp-tls/esp_tls_mbedtls.c b/components/esp-tls/esp_tls_mbedtls.c index 15cd24a04aa..6f5258869f4 100644 --- a/components/esp-tls/esp_tls_mbedtls.c +++ b/components/esp-tls/esp_tls_mbedtls.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -786,6 +786,10 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t // // PSK encryption mode is configured only if no certificate supplied and psk pointer not null ESP_LOGD(TAG, "ssl psk authentication"); + if (cfg->psk_hint_key->hint == NULL) { + ESP_LOGE(TAG, "Failed to use psk_hint_key"); + return ESP_ERR_MBEDTLS_SSL_CONF_PSK_FAILED; + } ret = mbedtls_ssl_conf_psk(&tls->conf, cfg->psk_hint_key->key, cfg->psk_hint_key->key_size, (const unsigned char *)cfg->psk_hint_key->hint, strlen(cfg->psk_hint_key->hint)); if (ret != 0) { diff --git a/components/esp-tls/test_apps/README.md b/components/esp-tls/test_apps/README.md index bf47d80ec64..1fb88efd154 100644 --- a/components/esp-tls/test_apps/README.md +++ b/components/esp-tls/test_apps/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C3 | +| ----------------- | ----- | -------- |