From 90ead3cfb8fff90f53f3dbab387e9de66b617872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 24 Jan 2023 15:39:41 +0100 Subject: [PATCH] Replace flawed memset_s usage memset_s() has a different signature than memset(3) or explicit_bzero(), thus the current code would not compile. Also memset_s() implementations are quite rare. Use the C23 standardized version memset_explicit(3). Fixes: 7a799ebb ("Ensure memory cleaning") --- configure.ac | 2 +- lib/defines.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 088a0a99..7acc3352 100644 --- a/configure.ac +++ b/configure.ac @@ -50,7 +50,7 @@ AC_CHECK_FUNCS(arc4random_buf futimes \ getutent initgroups lckpwdf lutimes \ setgroups updwtmp updwtmpx innetgr \ getspnam_r \ - memset_s explicit_bzero) + memset_explicit explicit_bzero) AC_SYS_LARGEFILE dnl Checks for typedefs, structures, and compiler characteristics. diff --git a/lib/defines.h b/lib/defines.h index 1a25e580..54053103 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -47,8 +47,8 @@ #include #include -#ifdef HAVE_MEMSET_S -# define memzero(ptr, size) memset_s((ptr), 0, (size)) +#ifdef HAVE_MEMSET_EXPLICIT +# define memzero(ptr, size) memset_explicit((ptr), 0, (size)) #elif defined HAVE_EXPLICIT_BZERO /* !HAVE_MEMSET_S */ # define memzero(ptr, size) explicit_bzero((ptr), (size)) #else /* !HAVE_MEMSET_S && HAVE_EXPLICIT_BZERO */