From: Alejandro Colomar Date: Mon, 12 Aug 2024 00:21:01 +0000 (+0200) Subject: lib/: Chain free(strzero(s)) X-Git-Tag: 4.17.0-rc1~83 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f5806e051166533efb54b764b3bfebddd7b56af6;p=thirdparty%2Fshadow.git lib/: Chain free(strzero(s)) This reduces the repetition of the argument, which could be error-prone. Signed-off-by: Alejandro Colomar --- diff --git a/lib/groupmem.c b/lib/groupmem.c index b28fcbc2c..23d7f054c 100644 --- a/lib/groupmem.c +++ b/lib/groupmem.c @@ -83,10 +83,9 @@ void gr_free(/*@only@*/struct group *grent) { free (grent->gr_name); - if (NULL != grent->gr_passwd) { - strzero (grent->gr_passwd); - free (grent->gr_passwd); - } + if (NULL != grent->gr_passwd) + free(strzero(grent->gr_passwd)); + gr_free_members(grent); free (grent); } diff --git a/lib/obscure.c b/lib/obscure.c index d10857bc5..59babd4bc 100644 --- a/lib/obscure.c +++ b/lib/obscure.c @@ -112,12 +112,9 @@ static /*@observer@*//*@null@*/const char *password_check ( } else if (strstr (wrapped, newmono) != NULL) { msg = _("rotated"); } - strzero (newmono); - strzero (oldmono); - strzero (wrapped); - free (newmono); - free (oldmono); - free (wrapped); + free(strzero(newmono)); + free(strzero(oldmono)); + free(strzero(wrapped)); return msg; } diff --git a/lib/pam_pass_non_interactive.c b/lib/pam_pass_non_interactive.c index 2c0207b1e..aa5c29bed 100644 --- a/lib/pam_pass_non_interactive.c +++ b/lib/pam_pass_non_interactive.c @@ -98,8 +98,7 @@ static int ni_conv (int num_msg, failed_conversation: for (count=0; count < num_msg; count++) { if (NULL != responses[count].resp) { - strzero(responses[count].resp); - free(responses[count].resp); + free(strzero(responses[count].resp)); responses[count].resp = NULL; } } diff --git a/lib/pwmem.c b/lib/pwmem.c index b68850e60..0f4e621ce 100644 --- a/lib/pwmem.c +++ b/lib/pwmem.c @@ -76,10 +76,9 @@ pw_free(/*@only@*/struct passwd *pwent) { if (pwent != NULL) { free (pwent->pw_name); - if (pwent->pw_passwd) { - strzero (pwent->pw_passwd); - free (pwent->pw_passwd); - } + if (pwent->pw_passwd) + free(strzero(pwent->pw_passwd)); + free (pwent->pw_gecos); free (pwent->pw_dir); free (pwent->pw_shell); diff --git a/lib/sgroupio.c b/lib/sgroupio.c index 90a130111..acb140d87 100644 --- a/lib/sgroupio.c +++ b/lib/sgroupio.c @@ -132,10 +132,9 @@ sgr_free(/*@only@*/struct sgrp *sgent) { size_t i; free (sgent->sg_name); - if (NULL != sgent->sg_passwd) { - strzero (sgent->sg_passwd); - free (sgent->sg_passwd); - } + if (NULL != sgent->sg_passwd) + free(strzero(sgent->sg_passwd)); + for (i = 0; NULL != sgent->sg_adm[i]; i++) { free (sgent->sg_adm[i]); } diff --git a/lib/shadowmem.c b/lib/shadowmem.c index e087ed5d7..99f1b1211 100644 --- a/lib/shadowmem.c +++ b/lib/shadowmem.c @@ -62,10 +62,9 @@ spw_free(/*@only@*/struct spwd *spent) { if (spent != NULL) { free (spent->sp_namp); - if (NULL != spent->sp_pwdp) { - strzero (spent->sp_pwdp); - free (spent->sp_pwdp); - } + if (NULL != spent->sp_pwdp) + free(strzero(spent->sp_pwdp)); + free (spent); } }