]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Replace flawed memset_s usage
authorChristian Göttsche <cgzones@googlemail.com>
Tue, 24 Jan 2023 14:39:41 +0000 (15:39 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Wed, 25 Jan 2023 10:07:25 +0000 (11:07 +0100)
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
lib/defines.h

index 088a0a9948b520e21bc04d613111000576de2b73..7acc335268584dc27b095c3f29007b1f842ec9a1 100644 (file)
@@ -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.
index 1a25e58070c70b3d444d8636aadd3d0bd1719f87..54053103a9e1292c8e6030f55a89d549ad52227c 100644 (file)
@@ -47,8 +47,8 @@
 #include <sys/time.h>
 #include <time.h>
 
-#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 */