Use MEMZERO() instead of its pattern

This patch implicitly adds the safety of SIZEOF_ARRAY(), since the calls
were using sizeof() instead.

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>
This commit is contained in:
Alejandro Colomar 2023-07-30 14:03:07 +02:00 committed by Iker Pedrosa
parent 64ab401239
commit f3ee47fe3f
5 changed files with 18 additions and 18 deletions

View File

@ -357,11 +357,11 @@ static int setup_user_limits (const char *uname)
char tempbuf[1024];
/* init things */
memzero (buf, sizeof (buf));
memzero (name, sizeof (name));
memzero (limits, sizeof (limits));
memzero (deflimits, sizeof (deflimits));
memzero (tempbuf, sizeof (tempbuf));
MEMZERO(buf);
MEMZERO(name);
MEMZERO(limits);
MEMZERO(deflimits);
MEMZERO(tempbuf);
/* start the checks */
fil = fopen (LIMITS_FILE, "r");
@ -378,7 +378,7 @@ static int setup_user_limits (const char *uname)
if (('#' == buf[0]) || ('\n' == buf[0])) {
continue;
}
memzero (tempbuf, sizeof (tempbuf));
MEMZERO(tempbuf);
/* a valid line should have a username, then spaces,
* then limits
* we allow the format:

View File

@ -80,7 +80,7 @@ void login_prompt (char *name, int namesize)
* removed.
*/
memzero (buf, sizeof buf);
MEMZERO(buf);
if (fgets (buf, sizeof buf, stdin) != buf) {
exit (EXIT_FAILURE);
}

View File

@ -899,7 +899,7 @@ static void change_passwd (struct group *gr)
erase_pass (cp);
cp = agetpass (_("Re-enter new password: "));
if (NULL == cp) {
memzero (pass, sizeof pass);
MEMZERO(pass);
exit (1);
}
@ -909,7 +909,7 @@ static void change_passwd (struct group *gr)
}
erase_pass (cp);
memzero (pass, sizeof pass);
MEMZERO(pass);
if (retries + 1 < RETRIES) {
puts (_("They don't match; try again"));
@ -929,7 +929,7 @@ static void change_passwd (struct group *gr)
Prog, salt, strerror (errno));
exit (1);
}
memzero (pass, sizeof pass);
MEMZERO(pass);
#ifdef SHADOWGRP
if (is_shadowgrp) {
gr->gr_passwd = SHADOW_PASSWD_STRING;

View File

@ -294,8 +294,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, sizeof orig);
memzero (pass, sizeof pass);
MEMZERO(orig);
MEMZERO(pass);
return -1;
}
if (warned && (strcmp (pass, cp) != 0)) {
@ -322,8 +322,8 @@ static int new_password (const struct passwd *pw)
}
cp = agetpass (_("Re-enter new password: "));
if (NULL == cp) {
memzero (orig, sizeof orig);
memzero (pass, sizeof pass);
MEMZERO(orig);
MEMZERO(pass);
return -1;
}
if (strcmp (cp, pass) != 0) {
@ -334,10 +334,10 @@ static int new_password (const struct passwd *pw)
break;
}
}
memzero (orig, sizeof orig);
MEMZERO(orig);
if (i == 0) {
memzero (pass, sizeof pass);
MEMZERO(pass);
return -1;
}
@ -346,7 +346,7 @@ static int new_password (const struct passwd *pw)
*/
salt = crypt_make_salt (NULL, NULL);
cp = pw_encrypt (pass, salt);
memzero (pass, sizeof pass);
MEMZERO(pass);
if (NULL == cp) {
fprintf (stderr,

View File

@ -167,7 +167,7 @@ static void catch_signals (unused int sig)
sleep (2);
(void) puts (_("Login incorrect"));
}
memzero (pass, sizeof pass);
MEMZERO(pass);
(void) alarm (0);
(void) signal (SIGALRM, SIG_DFL);
environ = newenvp; /* make new environment active */