summaryrefslogtreecommitdiff
path: root/lib/explicit_bzero.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-05-03 14:57:10 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-05-03 15:10:07 -0700
commit6bd47f4477904a55fc08345394bfab9cd7eae2eb (patch)
tree12c98d95f3e66d85164bcf3adbc8f8db1c391939 /lib/explicit_bzero.c
parent40149b871889461713dc73634498f9d2150b0249 (diff)
downloademacs-6bd47f4477904a55fc08345394bfab9cd7eae2eb.tar.gz
emacs-6bd47f4477904a55fc08345394bfab9cd7eae2eb.tar.bz2
emacs-6bd47f4477904a55fc08345394bfab9cd7eae2eb.zip
Update from Gnulib
This incorporates: 2020-05-03 attribute: new module 2020-04-13 explicit_bzero: improve code style 2020-04-13 explicit_bzero: On native Windows, use SecureZeroMemory 2020-04-13 explicit_bzero: use memset_s() when available 2020-04-04 maint: remove a stray inter-word space * build-aux/config.guess, build-aux/config.sub: * build-aux/gitlog-to-changelog, build-aux/update-copyright: * doc/misc/texinfo.tex, lib/explicit_bzero.c, lib/ieee754.in.h: * lib/nstrftime.c, m4/explicit_bzero.m4, m4/gnulib-common.m4: Copy from Gnulib. * lib/attribute.h: New file, copied from Gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
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 @@
# include <config.h>
#endif
+/* memset_s need this define */
+#if HAVE_MEMSET_S
+# define __STDC_WANT_LIB_EXT1__ 1
+#endif
+
#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. */
@@ -38,8 +48,12 @@
void
explicit_bzero (void *s, size_t len)
{
-#ifdef HAVE_EXPLICIT_MEMSET
- explicit_memset (s, 0, len);
+#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);
#else
memset (s, '\0', len);
# if defined __GNUC__ && !defined __clang__