From 9dc4b337b75a1581b80fab74d2d155a712205a16 Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Tue, 5 Nov 2024 18:50:34 +0100 Subject: [PATCH] mbedtls: ensure not to link against standard alloc/free Ensure that Mbed TLS will use its internal functions for heap memory management (allocation & free) instead of relying on standard libc functions. This helps solving link issues in some builds. Signed-off-by: Valerio Setti --- modules/mbedtls/configs/config-tls-generic.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/mbedtls/configs/config-tls-generic.h b/modules/mbedtls/configs/config-tls-generic.h index aff59f9e17e763..ddf7b3dddb3885 100644 --- a/modules/mbedtls/configs/config-tls-generic.h +++ b/modules/mbedtls/configs/config-tls-generic.h @@ -19,6 +19,14 @@ #define MBEDTLS_PLATFORM_EXIT_ALT #define MBEDTLS_NO_PLATFORM_ENTROPY +#if defined(CONFIG_MBEDTLS_ENABLE_HEAP) +/* Ensure that we're not using standard [m|c]alloc/free functions. + * mbedtls_memory_buffer_alloc_init() will set a local buffer to be used as + * heap and Mbed TLS will use internal function over it. + */ +#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS +#endif + #if defined(CONFIG_MBEDTLS_ZEROIZE_ALT) #define MBEDTLS_PLATFORM_ZEROIZE_ALT #endif