Use memset_s() if available
This commit is contained in:
parent
12281a7312
commit
9f2e0ba803
@ -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])
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
|
||||
#ifndef __STDC_WANT_LIB_EXT1__
|
||||
# define __STDC_WANT_LIB_EXT1__ 1
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user