summaryrefslogtreecommitdiff
path: root/missing/explicit_bzero.c
diff options
context:
space:
mode:
Diffstat (limited to 'missing/explicit_bzero.c')
-rw-r--r--missing/explicit_bzero.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/missing/explicit_bzero.c b/missing/explicit_bzero.c
index a7ff9cb517..59417e158e 100644
--- a/missing/explicit_bzero.c
+++ b/missing/explicit_bzero.c
@@ -1,12 +1,9 @@
#ifndef __STDC_WANT_LIB_EXT1__
-#define __STDC_WANT_LIB_EXT1__ 1
+#define __STDC_WANT_LIB_EXT1__ 1 /* for memset_s() */
#endif
#include "ruby/missing.h"
#include <string.h>
-#ifdef HAVE_MEMSET_S
-# include <string.h>
-#endif
#ifdef _WIN32
#include <windows.h>
@@ -17,9 +14,9 @@
/* OS support note:
* BSDs have explicit_bzero().
- * OS-X has memset_s().
+ * macOS has memset_s().
* Windows has SecureZeroMemory() since XP.
- * Linux has none. *Sigh*
+ * Linux has explicit_bzero() since glibc 2.25, musl libc 1.1.20.
*/
/*
@@ -33,7 +30,13 @@
#undef explicit_bzero
#ifndef HAVE_EXPLICIT_BZERO
- #ifdef HAVE_MEMSET_S
+ #ifdef HAVE_EXPLICIT_MEMSET
+void
+explicit_bzero(void *b, size_t len)
+{
+ (void)explicit_memset(b, 0, len);
+}
+ #elif defined HAVE_MEMSET_S
void
explicit_bzero(void *b, size_t len)
{