end{pw,sp}ent() can only be called after get{pw,sp}ent()

Calling them unconditionally can result in memory corruption.
This commit is contained in:
sin 2014-11-07 13:20:13 +00:00
parent 8745098fa4
commit 4339b507af
1 changed files with 0 additions and 2 deletions

View File

@ -73,7 +73,6 @@ getpw(void) { /* only run as root */
else
die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
}
endpwent();
rval = pw->pw_passwd;
#if HAVE_SHADOW_H
@ -82,7 +81,6 @@ getpw(void) { /* only run as root */
sp = getspnam(getenv("USER"));
if(!sp)
die("slock: cannot retrieve shadow entry (make sure to suid or sgid slock)\n");
endspent();
rval = sp->sp_pwdp;
}
#endif