aboutsummaryrefslogtreecommitdiffstats
path: root/lib/explicit_bzero.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/explicit_bzero.c')
-rw-r--r--lib/explicit_bzero.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c
index c82771fb1e3..b1f5acb7771 100644
--- a/lib/explicit_bzero.c
+++ b/lib/explicit_bzero.c
@@ -25,8 +25,18 @@
25# include <config.h> 25# include <config.h>
26#endif 26#endif
27 27
28/* memset_s need this define */
29#if HAVE_MEMSET_S
30# define __STDC_WANT_LIB_EXT1__ 1
31#endif
32
28#include <string.h> 33#include <string.h>
29 34
35#if defined _WIN32 && !defined __CYGWIN__
36# define WIN32_LEAN_AND_MEAN
37# include <windows.h>
38#endif
39
30#if _LIBC 40#if _LIBC
31/* glibc-internal users use __explicit_bzero_chk, and explicit_bzero 41/* glibc-internal users use __explicit_bzero_chk, and explicit_bzero
32 redirects to that. */ 42 redirects to that. */
@@ -38,8 +48,12 @@
38void 48void
39explicit_bzero (void *s, size_t len) 49explicit_bzero (void *s, size_t len)
40{ 50{
41#ifdef HAVE_EXPLICIT_MEMSET 51#if defined _WIN32 && !defined __CYGWIN__
42 explicit_memset (s, 0, len); 52 (void) SecureZeroMemory (s, len);
53#elif HAVE_EXPLICIT_MEMSET
54 explicit_memset (s, '\0', len);
55#elif HAVE_MEMSET_S
56 (void) memset_s (s, len, '\0', len);
43#else 57#else
44 memset (s, '\0', len); 58 memset (s, '\0', len);
45# if defined __GNUC__ && !defined __clang__ 59# if defined __GNUC__ && !defined __clang__