summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry LARONDE <tlaronde@kergis.com>2024-02-01 20:40:25 +0100
committerThierry LARONDE <tlaronde@kergis.com>2024-02-01 20:40:25 +0100
commit4866e00d737a1ece81c519ea867cfe16a0ae36b4 (patch)
treed0bb86ac125f97b5dbd400d2e1fc786a14958c47
parentcaa2d8e29adf43bb77fc00d718f7a0db4c2c35b1 (diff)
Also test for explicit_memset(3) support
explicit_bzero(3) is not provided by every system, and some provide explicit_memset(3) that is in the process of being standardized (furthermore, POSIX deprecates bzero(3) since memset(3) can do same or more).
-rw-r--r--AuDispose.c2
-rw-r--r--AuRead.c4
-rw-r--r--configure.ac2
-rw-r--r--meson.build4
4 files changed, 9 insertions, 3 deletions
diff --git a/AuDispose.c b/AuDispose.c
index 791232a..a449390 100644
--- a/AuDispose.c
+++ b/AuDispose.c
@@ -40,6 +40,8 @@ XauDisposeAuth (Xauth *auth)
if (auth->data) {
#ifdef HAVE_EXPLICIT_BZERO
(void) explicit_bzero (auth->data, auth->data_length);
+#elif HAVE_EXPLICIT_MEMSET
+ (void) explicit_memset (auth->data, 0, auth->data_length);
#else
(void) bzero (auth->data, auth->data_length);
#endif
diff --git a/AuRead.c b/AuRead.c
index 93774b0..649a1d8 100644
--- a/AuRead.c
+++ b/AuRead.c
@@ -58,6 +58,8 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
if (fread (data, sizeof (char), len, file) != len) {
#ifdef HAVE_EXPLICIT_BZERO
explicit_bzero (data, len);
+#elif HAVE_EXPLICIT_MEMSET
+ explicit_memset (data, 0, len);
#else
bzero (data, len);
#endif
@@ -107,6 +109,8 @@ XauReadAuth (FILE *auth_file)
if (local.data) {
#ifdef HAVE_EXPLICIT_BZERO
explicit_bzero (local.data, local.data_length);
+#elif HAVE_EXPLICIT_MEMSET
+ explicit_memset (local.data, 0, local.data_length);
#else
bzero (local.data, local.data_length);
#endif
diff --git a/configure.ac b/configure.ac
index 240610c..f062dbb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,7 +45,7 @@ XORG_DEFAULT_OPTIONS
AC_PROG_LN_S
# Checks for library functions.
-AC_CHECK_FUNCS([explicit_bzero pathconf])
+AC_CHECK_FUNCS([explicit_bzero explicit_memset pathconf])
# Obtain compiler/linker options for dependencies
PKG_CHECK_MODULES(XAU, xproto)
diff --git a/meson.build b/meson.build
index 6ca975a..a3dec49 100644
--- a/meson.build
+++ b/meson.build
@@ -19,7 +19,7 @@ cc = meson.get_compiler('c')
lib_args = []
-foreach f : ['explicit_bzero', 'pathconf']
+foreach f : ['explicit_bzero', 'explicit_memset', 'pathconf']
if cc.has_function(f)
lib_args += '-DHAVE_@0@'.format(f.to_upper())
endif
@@ -93,4 +93,4 @@ pkg.generate(
requires : 'xproto',
)
-subdir('man') \ No newline at end of file
+subdir('man')