diff options
author | Bastien Roucariès <rouca@debian.org> | 2020-04-13 01:09:15 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-04-14 00:15:02 +0200 |
commit | 6235c6c354a08976b7d6009eed7f1931a568e984 (patch) | |
tree | ae4d2b951708270baa34aa21aa66e454c7664969 | |
parent | 818572b398a9454e0edc1bb7f7135fc6af244694 (diff) | |
download | gnulib-6235c6c354a08976b7d6009eed7f1931a568e984.tar.gz |
explicit_bzero: On native Windows, use SecureZeroMemory().
* lib/explicit_bzero.c: Include <windows.h>.
(explicit_bzero): On native Windows, use SecureZeroMemory.
Signed-off-by: Bastien Roucariès <rouca@debian.org>
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/explicit_bzero.c | 9 |
2 files changed, 14 insertions, 1 deletions
@@ -1,5 +1,11 @@ 2020-04-13 Bastien Roucariès <rouca@debian.org> + explicit_bzero: On native Windows, use SecureZeroMemory(). + * lib/explicit_bzero.c: Include <windows.h>. + (explicit_bzero): On native Windows, use SecureZeroMemory. + +2020-04-13 Bastien Roucariès <rouca@debian.org> + explicit_bzero: Use memset_s() when available. * lib/explicit_bzero.c (__STDC_WANT_LIB_EXT1__): Define. (explicit_bzero): Use memset_s when available. diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c index 2168a52854..4897327918 100644 --- a/lib/explicit_bzero.c +++ b/lib/explicit_bzero.c @@ -32,6 +32,11 @@ #include <string.h> +#if defined _WIN32 && !defined __CYGWIN__ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +#endif + #if _LIBC /* glibc-internal users use __explicit_bzero_chk, and explicit_bzero redirects to that. */ @@ -43,7 +48,9 @@ void explicit_bzero (void *s, size_t len) { -#ifdef HAVE_EXPLICIT_MEMSET +#if defined _WIN32 && !defined __CYGWIN__ + (void) SecureZeroMemory (s, len); +#elif HAVE_EXPLICIT_MEMSET explicit_memset (s, 0, len); #elif HAVE_MEMSET_S (void) memset_s (s, len, '\0', len); |