diff --git a/configure.ac b/configure.ac index e50b0b63..809516a9 100644 --- a/configure.ac +++ b/configure.ac @@ -381,6 +381,7 @@ AC_CHECK_FUNC(clock_gettime, , [AC_CHECK_LIB(rt, clock_gettime)]) AC_CHECK_FUNC(fegetenv, , [AC_CHECK_LIB(m, fegetenv)]) AC_CHECK_FUNCS([SecureZeroMemory arc4random arc4random_buf posix_memalign]) +AC_CHECK_FUNCS([memset_s]) AC_SUBST([LIBTOOL_EXTRA_FLAGS]) diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index cc2dfbd4..2da72fa3 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -1,4 +1,7 @@ +#ifndef __STDC_WANT_LIB_EXT1__ +# define __STDC_WANT_LIB_EXT1__ 1 +#endif #include #include #include @@ -17,6 +20,10 @@ sodium_memzero(void * const pnt, const size_t len) { #ifdef HAVE_SECUREZEROMEMORY SecureZeroMemory(pnt, len); +#elif defined(HAVE_MEMSET_S) + if (memset_s(pnt, (rsize_t) len, 0, (rsize_t) len) != 0) { + abort(); + } #else volatile unsigned char *pnt_ = (volatile unsigned char *) pnt; size_t i = (size_t) 0U;