From 703f805f0990e8c4a661aa2d7d1d30cdd2601934 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Sat, 25 Feb 2023 15:19:52 +0000 Subject: [PATCH] Improve explicit_bzero detection Signed-off-by: Dave Rodgman --- library/platform_util.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/platform_util.c b/library/platform_util.c index 9ac57e141d..d8499bddc3 100644 --- a/library/platform_util.c +++ b/library/platform_util.c @@ -26,6 +26,11 @@ #define _POSIX_C_SOURCE 200112L #endif +#if !defined (_GNU_SOURCE) +/* Clang requires this to get support for explicit_bzero */ +#define _GNU_SOURCE +#endif + #include "common.h" #include "mbedtls/platform_util.h" @@ -84,7 +89,10 @@ * mbedtls_platform_zeroize() to use a suitable implementation for their * platform and needs. */ + #if !defined(MBEDTLS_PLATFORM_HAS_EXPLICIT_BZERO) && !defined(__STDC_LIB_EXT1__) \ + && !defined(_WIN32) static void *(*const volatile memset_func)(void *, int, size_t) = memset; +#endif void mbedtls_platform_zeroize(void *buf, size_t len) {