From: Marko Kreen Date: Sun, 7 Sep 2014 20:14:18 +0000 (+0300) Subject: string: use memset_s for explicit_bzero X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=57ab19322d1165ab342113b1e545b8256ee49b77;p=libusual.git string: use memset_s for explicit_bzero --- diff --git a/m4/usual.m4 b/m4/usual.m4 index 178fee1..123fa46 100644 --- a/m4/usual.m4 +++ b/m4/usual.m4 @@ -205,7 +205,7 @@ dnl AC_CHECK_FUNCS(basename dirname) # unstable, provide always AC_CHECK_FUNCS(strlcpy strlcat memmem getpeereid sigaction sigqueue) AC_CHECK_FUNCS(inet_ntop inet_pton poll getline memrchr regcomp) AC_CHECK_FUNCS(err errx warn warnx getprogname setprogname) -AC_CHECK_FUNCS(posix_memalign memalign valloc explicit_bzero) +AC_CHECK_FUNCS(posix_memalign memalign valloc explicit_bzero memset_s) AC_CHECK_FUNCS(getopt getopt_long getopt_long_only) AC_CHECK_FUNCS(fls flsl flsll ffs ffsl ffsll) AC_CHECK_FUNCS(fnmatch mbsnrtowcs nl_langinfo strtod_l) diff --git a/usual/base.h b/usual/base.h index 8b02464..769daa7 100644 --- a/usual/base.h +++ b/usual/base.h @@ -35,6 +35,11 @@ #define __EXTENSIONS__ #endif +/* C11 */ +#ifndef __STDC_WANT_LIB_EXT1__ +#define __STDC_WANT_LIB_EXT1__ 1 +#endif + #include #ifdef HAVE_SYS_PARAM_H #include diff --git a/usual/string.c b/usual/string.c index 6eec286..139d6ab 100644 --- a/usual/string.c +++ b/usual/string.c @@ -260,6 +260,13 @@ void explicit_bzero(void *buf, size_t len) SecureZeroMemory(buf, len); } +#elif defined(HAVE_MEMSET_S) + +void explicit_bzero(void *buf, size_t len) +{ + memset_s(buf, len, 0, len); +} + #else /* non-win32 */ /* avoid link-time optimization */