Merge pull request #446 from ikerexxe/spw_free

lib: check NULL before freeing passwd data
This commit is contained in:
Serge Hallyn 2021-11-22 07:32:32 -06:00 committed by GitHub
commit 3a0160beb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 13 deletions

View File

@ -93,6 +93,7 @@
void pw_free (/*@out@*/ /*@only@*/struct passwd *pwent)
{
if (pwent != NULL) {
free (pwent->pw_name);
if (pwent->pw_passwd) {
memzero (pwent->pw_passwd, strlen (pwent->pw_passwd));
@ -103,4 +104,5 @@ void pw_free (/*@out@*/ /*@only@*/struct passwd *pwent)
free (pwent->pw_shell);
free (pwent);
}
}

View File

@ -79,6 +79,7 @@
void spw_free (/*@out@*/ /*@only@*/struct spwd *spent)
{
if (spent != NULL) {
free (spent->sp_namp);
if (NULL != spent->sp_pwdp) {
memzero (spent->sp_pwdp, strlen (spent->sp_pwdp));
@ -86,4 +87,5 @@ void spw_free (/*@out@*/ /*@only@*/struct spwd *spent)
}
free (spent);
}
}