lib: check NULL before freeing passwd data
Add an additional NULL check condition in spw_free() and pw_free() to avoid freeing an already empty pointer. Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
This commit is contained in:
parent
02916e9cb2
commit
d594243fbb
@ -93,6 +93,7 @@
|
|||||||
|
|
||||||
void pw_free (/*@out@*/ /*@only@*/struct passwd *pwent)
|
void pw_free (/*@out@*/ /*@only@*/struct passwd *pwent)
|
||||||
{
|
{
|
||||||
|
if (pwent != NULL) {
|
||||||
free (pwent->pw_name);
|
free (pwent->pw_name);
|
||||||
if (pwent->pw_passwd) {
|
if (pwent->pw_passwd) {
|
||||||
memzero (pwent->pw_passwd, strlen (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->pw_shell);
|
||||||
free (pwent);
|
free (pwent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
|
|
||||||
void spw_free (/*@out@*/ /*@only@*/struct spwd *spent)
|
void spw_free (/*@out@*/ /*@only@*/struct spwd *spent)
|
||||||
{
|
{
|
||||||
|
if (spent != NULL) {
|
||||||
free (spent->sp_namp);
|
free (spent->sp_namp);
|
||||||
if (NULL != spent->sp_pwdp) {
|
if (NULL != spent->sp_pwdp) {
|
||||||
memzero (spent->sp_pwdp, strlen (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);
|
free (spent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user