From b3ba348d0816628c9a098e83cafc85fbe237635c Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 29 Sep 2018 19:19:23 +0100 Subject: [PATCH] Provides explicit_memset supports/NetBSD. Similar to explicit_bzero function is to defeat compiler optimisation. --- configure.ac | 2 +- src/libsodium/sodium/utils.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0a7edbc1..35c42746 100644 --- a/configure.ac +++ b/configure.ac @@ -791,7 +791,7 @@ dnl Checks for functions and headers AC_FUNC_ALLOCA AS_IF([test "x$EMSCRIPTEN" = "x"],[ AC_CHECK_FUNCS([arc4random arc4random_buf]) - AC_CHECK_FUNCS([mmap mlock madvise mprotect memset_s explicit_bzero nanosleep]) + AC_CHECK_FUNCS([mmap mlock madvise mprotect memset_s explicit_bzero explicit_memset nanosleep]) ]) AC_CHECK_FUNCS([posix_memalign getpid]) diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index 83bc04d3..007f284a 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -110,6 +110,8 @@ sodium_memzero(void *const pnt, const size_t len) } #elif defined(HAVE_EXPLICIT_BZERO) explicit_bzero(pnt, len); +#elif defined(HAVE_EXPLICIT_MEMSET) + explicit_memset(pnt, 0, len); #elif HAVE_WEAK_SYMBOLS memset(pnt, 0, len); _sodium_dummy_symbol_to_prevent_memzero_lto(pnt, len);