From: Alejandro Colomar Date: Tue, 14 Oct 2025 11:01:54 +0000 (+0200) Subject: */: s/MEMZERO/memzero_a/ X-Git-Tag: 4.19.0-rc1~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd3a5077b0ba74d1429011bc0d83dcd2f227a52d;p=thirdparty%2Fshadow.git */: s/MEMZERO/memzero_a/ This name better reflects that it handles arrays, and doesn't shout. Signed-off-by: Alejandro Colomar --- diff --git a/lib/limits.c b/lib/limits.c index b806e3ca8..2d80a3217 100644 --- a/lib/limits.c +++ b/lib/limits.c @@ -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: diff --git a/lib/loginprompt.c b/lib/loginprompt.c index beebcf3ae..51cbc3de3 100644 --- a/lib/loginprompt.c +++ b/lib/loginprompt.c @@ -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); } diff --git a/lib/string/README b/lib/string/README index 0c7c4b3f4..91355ed27 100644 --- a/lib/string/README +++ b/lib/string/README @@ -86,7 +86,7 @@ memset/ - Memory zeroing memzero() Synonym of explicit_bzero(3). - MEMZERO() + memzero_a() Like memzero(), but takes an array. strzero() diff --git a/lib/string/memset/memzero.h b/lib/string/memset/memzero.h index caa4c0636..ea7c267bf 100644 --- a/lib/string/memset/memzero.h +++ b/lib/string/memset/memzero.h @@ -16,13 +16,15 @@ #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) { diff --git a/src/gpasswd.c b/src/gpasswd.c index 14ffedb81..6c534b6dd 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -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"), diff --git a/src/passwd.c b/src/passwd.c index f6c4f47a4..336af7dfe 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -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,