From 6235c6c354a08976b7d6009eed7f1931a568e984 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bastien=20Roucari=C3=A8s?= Date: Mon, 13 Apr 2020 01:09:15 +0200 Subject: [PATCH] explicit_bzero: On native Windows, use SecureZeroMemory(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * lib/explicit_bzero.c: Include . (explicit_bzero): On native Windows, use SecureZeroMemory. Signed-off-by: Bastien Roucariès --- ChangeLog | 6 ++++++ lib/explicit_bzero.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8bb1465d82..0d4b34e39d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-04-13 Bastien Roucariès + + explicit_bzero: On native Windows, use SecureZeroMemory(). + * lib/explicit_bzero.c: Include . + (explicit_bzero): On native Windows, use SecureZeroMemory. + 2020-04-13 Bastien Roucariès 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 +#if defined _WIN32 && !defined __CYGWIN__ +# define WIN32_LEAN_AND_MEAN +# include +#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); -- 2.39.5