]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
*/: s/MEMZERO/memzero_a/
authorAlejandro Colomar <alx@kernel.org>
Tue, 14 Oct 2025 11:01:54 +0000 (13:01 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 28 Nov 2025 02:50:48 +0000 (20:50 -0600)
This name better reflects that it handles arrays, and doesn't shout.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/limits.c
lib/loginprompt.c
lib/string/README
lib/string/memset/memzero.h
src/gpasswd.c
src/passwd.c

index b806e3ca8c2b26e9c6295a95e70ea8b4f1d7b076..2d80a3217ac5ad52724a5b2e20a24ad0fc182551 100644 (file)
@@ -349,11 +349,11 @@ static int setup_user_limits (const char *uname)
        char tempbuf[1024];
 
        /* init things */
-       MEMZERO(buf);
-       MEMZERO(name);
-       MEMZERO(limits);
-       MEMZERO(deflimits);
-       MEMZERO(tempbuf);
+       memzero_a(buf);
+       memzero_a(name);
+       memzero_a(limits);
+       memzero_a(deflimits);
+       memzero_a(tempbuf);
 
        /* start the checks */
        fil = fopen (LIMITS_FILE, "r");
@@ -370,7 +370,7 @@ static int setup_user_limits (const char *uname)
                if (strprefix(buf, "#") || strprefix(buf, "\n")) {
                        continue;
                }
-               MEMZERO(tempbuf);
+               memzero_a(tempbuf);
                /* a valid line should have a username, then spaces,
                 * then limits
                 * we allow the format:
index beebcf3ae22d3c5c6d568bf2d02cd5f0b49ee040..51cbc3de3ff1782bbd4366207a0242b3249d80e1 100644 (file)
@@ -82,7 +82,7 @@ login_prompt(char *name, int namesize)
         * removed.
         */
 
-       MEMZERO(buf);
+       memzero_a(buf);
        if (fgets (buf, sizeof buf, stdin) != buf) {
                exit (EXIT_FAILURE);
        }
index 0c7c4b3f41c1896e076bb5758b393a9fd4c392c1..91355ed2794e8d6c4a24c8155b9a790404b2b60a 100644 (file)
@@ -86,7 +86,7 @@ memset/ - Memory zeroing
 
     memzero()
        Synonym of explicit_bzero(3).
-    MEMZERO()
+    memzero_a()
        Like memzero(), but takes an array.
 
     strzero()
index caa4c0636b476dd98a7985d6c928f44694c0b471..ea7c267bf31fd963d8c5c161e8aa9874798d2d0f 100644 (file)
 #include "sizeof.h"
 
 
-#define MEMZERO(arr)  memzero(arr, sizeof_a(arr))
+// memzero_a - memory zero (explicit) array
+#define memzero_a(arr)  memzero(arr, sizeof_a(arr))
 
 
 inline void *memzero(void *ptr, size_t size);
 inline char *strzero(char *s);
 
 
+// memzero - memory zero (explicit)
 inline void *
 memzero(void *ptr, size_t size)
 {
@@ -38,6 +40,7 @@ memzero(void *ptr, size_t size)
 }
 
 
+// strzero - string zero (explicit)
 inline char *
 strzero(char *s)
 {
index 14ffedb81e58f8f252145d7213388e3fe53d29b6..6c534b6dd04fc00333301b323619ac766976a54b 100644 (file)
@@ -826,7 +826,7 @@ static void change_passwd (struct group *gr)
                erase_pass (cp);
                cp = agetpass (_("Re-enter new password: "));
                if (NULL == cp) {
-                       MEMZERO(pass);
+                       memzero_a(pass);
                        exit (1);
                }
 
@@ -836,7 +836,7 @@ static void change_passwd (struct group *gr)
                }
 
                erase_pass (cp);
-               MEMZERO(pass);
+               memzero_a(pass);
 
                if (retries + 1 < RETRIES) {
                        puts (_("They don't match; try again"));
@@ -850,7 +850,7 @@ static void change_passwd (struct group *gr)
 
        salt = crypt_make_salt (NULL, NULL);
        cp = pw_encrypt (pass, salt);
-       MEMZERO(pass);
+       memzero_a(pass);
        if (NULL == cp) {
                fprintf (stderr,
                         _("%s: failed to crypt password with salt '%s': %s\n"),
index f6c4f47a413fbcb5e67c6bbb13059d33c772afd1..336af7dfea0ffab977b2dd4531a2b0aab18f4d96 100644 (file)
@@ -296,7 +296,7 @@ static int new_password (const struct passwd *pw)
                erase_pass (cp);
                if (ret == -1) {
                        (void) fputs (_("Password is too long.\n"), stderr);
-                       MEMZERO(pass);
+                       memzero_a(pass);
                        return -1;
                }
        } else {
@@ -304,8 +304,8 @@ static int new_password (const struct passwd *pw)
                for (i = getdef_num ("PASS_CHANGE_TRIES", 5); i > 0; i--) {
                        cp = agetpass (_("New password: "));
                        if (NULL == cp) {
-                               MEMZERO(orig);
-                               MEMZERO(pass);
+                               memzero_a(orig);
+                               memzero_a(pass);
                                return -1;
                        }
                        if (warned && !streq(pass, cp)) {
@@ -315,8 +315,8 @@ static int new_password (const struct passwd *pw)
                        erase_pass (cp);
                        if (ret == -1) {
                                (void) fputs (_("Password is too long.\n"), stderr);
-                               MEMZERO(orig);
-                               MEMZERO(pass);
+                               memzero_a(orig);
+                               memzero_a(pass);
                                return -1;
                        }
 
@@ -338,8 +338,8 @@ static int new_password (const struct passwd *pw)
                        }
                        cp = agetpass (_("Re-enter new password: "));
                        if (NULL == cp) {
-                               MEMZERO(orig);
-                               MEMZERO(pass);
+                               memzero_a(orig);
+                               memzero_a(pass);
                                return -1;
                        }
                        if (!streq(cp, pass)) {
@@ -350,10 +350,10 @@ static int new_password (const struct passwd *pw)
                                break;
                        }
                }
-               MEMZERO(orig);
+               memzero_a(orig);
 
                if (i == 0) {
-                       MEMZERO(pass);
+                       memzero_a(pass);
                        return -1;
                }
        }
@@ -364,7 +364,7 @@ static int new_password (const struct passwd *pw)
         */
        salt = crypt_make_salt (NULL, NULL);
        cp = pw_encrypt (pass, salt);
-       MEMZERO(pass);
+       memzero_a(pass);
 
        if (NULL == cp) {
                fprintf (stderr,