Fix a bug where the ssl context is used after it's nullified
When not using DEBUG_C, but using the DTLS CID feature -
a null pointer was accessed in ssl_tls.c.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index f16157a..821506f 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -693,8 +693,9 @@
const mbedtls_cipher_info_t *cipher_info;
const mbedtls_md_info_t *md_info;
-#if !defined(MBEDTLS_DEBUG_C)
- ssl = NULL; /* make sure we don't use it except for this case */
+#if !defined(MBEDTLS_DEBUG_C) && \
+ !defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
+ ssl = NULL; /* make sure we don't use it except for these cases */
(void) ssl;
#endif
diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh
index f30795c..00939a7 100755
--- a/tests/scripts/all.sh
+++ b/tests/scripts/all.sh
@@ -2083,6 +2083,18 @@
tests/compat.sh
}
+component_test_CID_no_debug() {
+ msg "build: Connection ID enabled, debug disabled"
+ scripts/config.py unset MBEDTLS_DEBUG_C
+ scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID
+
+ CC=gcc cmake .
+ make
+
+ msg "test: Connection ID enabled, debug disabled"
+ make test
+}
+
component_test_ssl_alloc_buffer_and_mfl () {
msg "build: default config with memory buffer allocator and MFL extension"
scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C