aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2020-04-19 19:38:53 +0300
committerEli Zaretskii2020-04-19 19:38:53 +0300
commit3f8b771da96f9a55dd5ed322104135a0c2c6f2e4 (patch)
tree6362a2a1f4bc07411560a517a1557af77c8b4f75 /src
parent65990f47ccd6f1a3558910d71701a6f029c35433 (diff)
downloademacs-3f8b771da96f9a55dd5ed322104135a0c2c6f2e4.tar.gz
emacs-3f8b771da96f9a55dd5ed322104135a0c2c6f2e4.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/w32.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/w32.c b/src/w32.c
index 42c832a5937..0f69e652a57 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2370,6 +2370,26 @@ srandom (int seed)
2370 iz = rand () % RAND_MAX_Z; 2370 iz = rand () % RAND_MAX_Z;
2371} 2371}
2372 2372
2373/* Emulate explicit_bzero. This is to avoid using the Gnulib version,
2374 because it calls SecureZeroMemory at will, disregarding systems
2375 older than Windows XP, which didn't have that function. We want to
2376 avoid having that function as dependency in builds that need to
2377 support systems older than Windows XP, otherwise Emacs will refuse
2378 to start on those systems. */
2379void
2380explicit_bzero (void *buf, size_t len)
2381{
2382#if _WIN32_WINNT >= 0x0501
2383 /* We are compiling for XP or newer, most probably with MinGW64.
2384 We can use SecureZeroMemory. */
2385 SecureZeroMemory (buf, len);
2386#else
2387 memset (buf, 0, len);
2388 /* Compiler barrier. */
2389 asm volatile ("" ::: "memory");
2390#endif
2391}
2392
2373/* Return the maximum length in bytes of a multibyte character 2393/* Return the maximum length in bytes of a multibyte character
2374 sequence encoded in the current ANSI codepage. This is required to 2394 sequence encoded in the current ANSI codepage. This is required to
2375 correctly walk the encoded file names one character at a time. */ 2395 correctly walk the encoded file names one character at a time. */