Use explicit_bzero if available

This commit is contained in:
Frank Denis 2014-05-09 13:06:39 -07:00
parent 290632a193
commit bfeec26358
2 changed files with 3 additions and 1 deletions

View File

@ -355,7 +355,7 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[
AC_CHECK_FUNCS([memset_s]) AC_CHECK_FUNCS([memset_s])
]) ])
AC_CHECK_FUNCS([mlock VirtualLock]) AC_CHECK_FUNCS([mlock VirtualLock])
AC_CHECK_FUNCS([SecureZeroMemory posix_memalign]) AC_CHECK_FUNCS([SecureZeroMemory explicit_bzero posix_memalign])
AC_SUBST([LIBTOOL_EXTRA_FLAGS]) AC_SUBST([LIBTOOL_EXTRA_FLAGS])

View File

@ -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) { if (memset_s(pnt, (rsize_t) len, 0, (rsize_t) len) != 0) {
abort(); abort();
} }
#elif defined(HAVE_EXPLICIT_BZERO)
explicit_bzero(pnt, len);
#else #else
volatile unsigned char *pnt_ = (volatile unsigned char *) pnt; volatile unsigned char *pnt_ = (volatile unsigned char *) pnt;
size_t i = (size_t) 0U; size_t i = (size_t) 0U;