]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
memzero.h: Move memzero() and strzero() to their own header
authorAlejandro Colomar <alx@kernel.org>
Sun, 30 Jul 2023 11:18:03 +0000 (13:18 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 1 Sep 2023 07:39:23 +0000 (09:39 +0200)
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
24 files changed:
lib/Makefile.am
lib/commonio.c
lib/defines.h
lib/failure.c
lib/groupmem.c
lib/limits.c
lib/log.c
lib/loginprompt.c
lib/memzero.h [new file with mode: 0644]
lib/obscure.c
lib/pwauth.c
lib/pwmem.c
lib/sgroupio.c
lib/shadowmem.c
src/chage.c
src/faillog.c
src/gpasswd.c
src/groupadd.c
src/lastlog.c
src/login.c
src/passwd.c
src/sulogin.c
src/useradd.c
src/usermod.c

index ca73313dc242f103c9d00918b3644e60ca5f6286..e778004e7e392ff6b6c15c8f46b44d639f1ac186 100644 (file)
@@ -85,6 +85,7 @@ libshadow_la_SOURCES = \
        mail.c \
        mempcpy.c \
        mempcpy.h \
+       memzero.h \
        motd.c \
        myname.c \
        nss.c \
index c6459a2ec0586540049b46fb9dd720e3d2010f09..6d744ad142a5782efebd0617d35ff7b6b5b85468 100644 (file)
@@ -23,6 +23,7 @@
 #include <signal.h>
 
 #include "alloc.h"
+#include "memzero.h"
 #include "nscd.h"
 #include "sssd.h"
 #ifdef WITH_TCB
index b289a72dfff8ae722658c6c7584fce1520f101db..a24a0c7d3e2c66e3ffde9e1bc93d0db22afb470f 100644 (file)
 #include <sys/time.h>
 #include <time.h>
 
-#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 */
-static inline void memzero(void *ptr, size_t size)
-{
-       ptr = memset(ptr, '\0', size);
-       __asm__ __volatile__ ("" : : "r"(ptr) : "memory");
-}
-#endif                                 /* !HAVE_MEMSET_S && !HAVE_EXPLICIT_BZERO */
-
-#define strzero(s) memzero(s, strlen(s))       /* warning: evaluates twice */
-
 #include <dirent.h>
 
 /*
index 205eec9cabe048ef8d503753a7d9795f95d5e2b6..1d2d910ab2611c1082cd5b7df0d8c90b166f1dbf 100644 (file)
 #include "defines.h"
 #include "faillog.h"
 #include "failure.h"
+#include "memzero.h"
 #include "prototypes.h"
+
+
 #define        YEAR    (365L*DAY)
 /*
  * failure - make failure entry
index a1e18dca050afb8a0d5cf4baae5e29aa946326fe..271724fbd5362ef38cb600f24d1ed3d5ee54b980 100644 (file)
@@ -13,6 +13,7 @@
 #ident "$Id$"
 
 #include "alloc.h"
+#include "memzero.h"
 #include "prototypes.h"
 #include "defines.h"
 #include "groupio.h"
index ef8cb92096e8e344578677bfc421047826fc873c..96998e9e813f641a84036089be6a70381c130e58 100644 (file)
@@ -29,6 +29,7 @@
 #include "getdef.h"
 #include "shadowlog.h"
 #include <sys/resource.h>
+#include "memzero.h"
 #ifndef LIMITS_FILE
 #define LIMITS_FILE "/etc/limits"
 #endif
index fb867b274c2951421c0cfc1693996a3fc56467c9..8b3e564e5c3e0e2b2d350797bbf013864cdd13b0 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -17,6 +17,7 @@
 #include <time.h>
 #include "defines.h"
 #include <lastlog.h>
+#include "memzero.h"
 #include "prototypes.h"
 
 /*
index d1af0e3989fe5d800dd92e7b231e6896d5076af5..bf8c3cdda706eb9d2fa39425a2c785a6c6d95746 100644 (file)
@@ -16,6 +16,7 @@
 #include <signal.h>
 
 #include "alloc.h"
+#include "memzero.h"
 #include "prototypes.h"
 #include "defines.h"
 #include "getdef.h"
diff --git a/lib/memzero.h b/lib/memzero.h
new file mode 100644 (file)
index 0000000..00000b9
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * SPDX-FileCopyrightText: 2022-2023, Christian Göttsche <cgzones@googlemail.com>
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+#ifndef SHADOW_INCLUDE_LIBMISC_MEMZERO_H_
+#define SHADOW_INCLUDE_LIBMISC_MEMZERO_H_
+
+
+#include <config.h>
+
+#include <stddef.h>
+#include <string.h>
+#include <strings.h>
+
+
+#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 */
+static inline void memzero(void *ptr, size_t size)
+{
+       ptr = memset(ptr, '\0', size);
+       __asm__ __volatile__ ("" : : "r"(ptr) : "memory");
+}
+#endif                                 /* !HAVE_MEMSET_S && !HAVE_EXPLICIT_BZERO */
+
+#define strzero(s) memzero(s, strlen(s))       /* warning: evaluates twice */
+
+
+#endif  // include guard
index 88a87735616904d23ae870d4092a27cc0f4f9bdb..ccffb71db1ae4a779420848e2d548148236deb98 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdio.h>
 
 #include "alloc.h"
+#include "memzero.h"
 #include "prototypes.h"
 #include "defines.h"
 #include "getdef.h"
index df67b04e13be454ad42e38e0308fa8009b7555ed..693b3b7df4f001c240237875b446d791d6bd5fb1 100644 (file)
@@ -20,6 +20,7 @@
 #include <unistd.h>
 #include "prototypes.h"
 #include "defines.h"
+#include "memzero.h"
 #include "pwauth.h"
 #include "getdef.h"
 #ifdef SKEY
index 4e966a4249bf76d63cd6a4a3e42fc803a25ed93d..3d868a850b7c7c6e3afe68f9bca807f3f4c2d694 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "alloc.h"
 #include "defines.h"
+#include "memzero.h"
 #include "prototypes.h"
 #include "pwio.h"
 
index 02ff95a11f6ad3b0f5c206ae66b6d43f32a79554..cbbdff7889d58d5e7a11b6b4157761b22bc732b0 100644 (file)
@@ -19,6 +19,7 @@
 #include "defines.h"
 #include "commonio.h"
 #include "getdef.h"
+#include "memzero.h"
 #include "sgroupio.h"
 
 /*@null@*/ /*@only@*/struct sgrp *__sgr_dup (const struct sgrp *sgent)
index 93bcb12dde4ab00a175998fc6f4f5de9b6529eea..c3c7c4cc34d50a6ba66be6ac8031600ac410bd87 100644 (file)
@@ -18,6 +18,7 @@
 #include <stdio.h>
 
 #include "alloc.h"
+#include "memzero.h"
 #include "shadowio.h"
 
 /*@null@*/ /*@only@*/struct spwd *__spw_dup (const struct spwd *spent)
index b11ed3d8985bdc2772983fb8cb42ab7044c067ab..b8a11e8c4a61a6bbb7683c0f87220aa57cdaf771 100644 (file)
@@ -29,6 +29,7 @@
 #include "alloc.h"
 #include "prototypes.h"
 #include "defines.h"
+#include "memzero.h"
 #include "pwio.h"
 #include "shadowio.h"
 #include "shadowlog.h"
index 1fee5c9b0afe6a2b8f4e5988294b9a5c53ee46ca..ab60775a440811867b80f071584e2a7c1edc746f 100644 (file)
@@ -20,6 +20,7 @@
 #include <assert.h>
 #include "defines.h"
 #include "faillog.h"
+#include "memzero.h"
 #include "prototypes.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
index 3b76ff8ed19d5a28fc4472b655a0889fd28a4899..853cb03ae2953e6fabcfc8930aee8f184e6b2de7 100644 (file)
@@ -23,6 +23,7 @@
 #include "alloc.h"
 #include "defines.h"
 #include "groupio.h"
+#include "memzero.h"
 #include "nscd.h"
 #include "sssd.h"
 #include "prototypes.h"
index 2eda1c68045d90b3fe6f8aaec88997afbcfec9d5..462a4ccd2ee5aeda7d14f14c64fa12a5ab7a59d1 100644 (file)
@@ -27,6 +27,7 @@
 #include "defines.h"
 #include "getdef.h"
 #include "groupio.h"
+#include "memzero.h"
 #include "nscd.h"
 #include "sssd.h"
 #include "prototypes.h"
index 1db668871b36fbb8504d52c5f14e11604a22a7e0..cd80de2e82ac80f52aab6d63904a7c3188538b26 100644 (file)
@@ -25,6 +25,7 @@
 #include "defines.h"
 #include "prototypes.h"
 #include "getdef.h"
+#include "memzero.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
 #include "shadowlog.h"
index 8a109801b3b319768b63c4f58f4e9ffb1d08250f..84002232d4840b103835b9d4052fd1cb52254cb3 100644 (file)
@@ -30,6 +30,7 @@
 #include "faillog.h"
 #include "failure.h"
 #include "getdef.h"
+#include "memzero.h"
 #include "prototypes.h"
 #include "pwauth.h"
 /*@-exitarg@*/
index 5d59e8c4b6bdd74756801f0605a1202c43e4acc4..a89790db6157b7fc1c3fb11cfae35b13abd5371e 100644 (file)
@@ -23,6 +23,7 @@
 #include "alloc.h"
 #include "defines.h"
 #include "getdef.h"
+#include "memzero.h"
 #include "nscd.h"
 #include "sssd.h"
 #include "prototypes.h"
index 080b92f107e51d182cb7a2e5c1f007cd6af01ec0..14bec6ae71b63d7bb3a86f5a49795b4e329f31ce 100644 (file)
@@ -18,6 +18,7 @@
 #include <sys/ioctl.h>
 #include "defines.h"
 #include "getdef.h"
+#include "memzero.h"
 #include "prototypes.h"
 #include "pwauth.h"
 /*@-exitarg@*/
index 11d0bc9cb4b97b902415eb81aa83e472573b21b5..76a4d6495edda1713fcc5ec2335b54a6bc4a45c8 100644 (file)
@@ -42,6 +42,7 @@
 #include "faillog.h"
 #include "getdef.h"
 #include "groupio.h"
+#include "memzero.h"
 #include "nscd.h"
 #include "sssd.h"
 #include "prototypes.h"
index 61cd11a8dcee8a884ba7db343ee078f182c20a21..72a98f1f8ea2c3499d1e628cbbe7700f18131dfe 100644 (file)
@@ -37,6 +37,7 @@
 #include "faillog.h"
 #include "getdef.h"
 #include "groupio.h"
+#include "memzero.h"
 #include "nscd.h"
 #include "sssd.h"
 #include "prototypes.h"