[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3f8b771: Don't use Gnulib's explicit_bzero on MS-Windows
From: |
Eli Zaretskii |
Subject: |
master 3f8b771: Don't use Gnulib's explicit_bzero on MS-Windows |
Date: |
Sun, 19 Apr 2020 12:41:33 -0400 (EDT) |
branch: master
commit 3f8b771da96f9a55dd5ed322104135a0c2c6f2e4
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Don't use Gnulib's explicit_bzero on MS-Windows
This is a preventive change, since Gnulib was recently changed
its explicit_bzero to call SecureZeroMemory on MS-Windows,
disregarding systems older than XP, which didn't have it.
* src/w32.c (explicit_bzero): New function.
* nt/mingw-cfg.site (ac_cv_func_explicit_bzero): Avoid using the
Gnulib replacement for explicit_bzero.
* nt/inc/ms-w32.h (explicit_bzero): Add prototype.
---
nt/inc/ms-w32.h | 1 +
nt/mingw-cfg.site | 1 +
src/w32.c | 20 ++++++++++++++++++++
3 files changed, 22 insertions(+)
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index 1cce2c3..cbe35ea 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -440,6 +440,7 @@ extern int alarm (int);
extern int sys_kill (pid_t, int);
+extern void explicit_bzero (void *, size_t);
/* For integration with MSDOS support. */
#define getdisk() (_getdrive () - 1)
diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site
index 2271eef..2e898c7 100644
--- a/nt/mingw-cfg.site
+++ b/nt/mingw-cfg.site
@@ -109,6 +109,7 @@ ac_cv_func_futimens=not-needed
gl_cv_func_futimens_works="not-needed-so-yes"
ac_cv_func_utimensat=yes
gl_cv_func_utimensat_works=yes
+ac_cv_func_explicit_bzero=yes
# Aliased to _commit in ms-w32.h
ac_cv_func_fsync=yes
ac_cv_func_fdatasync=yes
diff --git a/src/w32.c b/src/w32.c
index 42c832a..0f69e65 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2370,6 +2370,26 @@ srandom (int seed)
iz = rand () % RAND_MAX_Z;
}
+/* Emulate explicit_bzero. This is to avoid using the Gnulib version,
+ because it calls SecureZeroMemory at will, disregarding systems
+ older than Windows XP, which didn't have that function. We want to
+ avoid having that function as dependency in builds that need to
+ support systems older than Windows XP, otherwise Emacs will refuse
+ to start on those systems. */
+void
+explicit_bzero (void *buf, size_t len)
+{
+#if _WIN32_WINNT >= 0x0501
+ /* We are compiling for XP or newer, most probably with MinGW64.
+ We can use SecureZeroMemory. */
+ SecureZeroMemory (buf, len);
+#else
+ memset (buf, 0, len);
+ /* Compiler barrier. */
+ asm volatile ("" ::: "memory");
+#endif
+}
+
/* Return the maximum length in bytes of a multibyte character
sequence encoded in the current ANSI codepage. This is required to
correctly walk the encoded file names one character at a time. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 3f8b771: Don't use Gnulib's explicit_bzero on MS-Windows,
Eli Zaretskii <=