aboutsummaryrefslogtreecommitdiffstats
path: root/lib/explicit_bzero.c
diff options
context:
space:
mode:
authorPaul Eggert2020-05-03 14:57:10 -0700
committerPaul Eggert2020-05-03 15:10:07 -0700
commit6bd47f4477904a55fc08345394bfab9cd7eae2eb (patch)
tree12c98d95f3e66d85164bcf3adbc8f8db1c391939 /lib/explicit_bzero.c
parent40149b871889461713dc73634498f9d2150b0249 (diff)
downloademacs-6bd47f4477904a55fc08345394bfab9cd7eae2eb.tar.gz
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 @@
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__