From bfeec263584eaac0bacb3c33a29858de03b2b097 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 9 May 2014 13:06:39 -0700 Subject: [PATCH] Use explicit_bzero if available --- 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 8b4f6c56..3f5401b6 100644 --- a/configure.ac +++ b/configure.ac @@ -355,7 +355,7 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[ AC_CHECK_FUNCS([memset_s]) ]) AC_CHECK_FUNCS([mlock VirtualLock]) -AC_CHECK_FUNCS([SecureZeroMemory posix_memalign]) +AC_CHECK_FUNCS([SecureZeroMemory explicit_bzero posix_memalign]) AC_SUBST([LIBTOOL_EXTRA_FLAGS]) diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index 3bfafc5d..6aeee712 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -28,6 +28,8 @@ sodium_memzero(void * const pnt, const size_t len) if (memset_s(pnt, (rsize_t) len, 0, (rsize_t) len) != 0) { abort(); } +#elif defined(HAVE_EXPLICIT_BZERO) + explicit_bzero(pnt, len); #else volatile unsigned char *pnt_ = (volatile unsigned char *) pnt; size_t i = (size_t) 0U;