aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2014-11-07 13:20:13 +0000
committersin <sin@2f30.org>2014-11-09 13:10:02 +0000
commit4339b507af01421e2deab63ca9ac3c5bdae5f4cc (patch)
tree3b63f8444d7090ea08cfd5c32f69501dc87deeec
parent8745098fa440ef3bf1d8e173dcd91514b34600c6 (diff)
end{pw,sp}ent() can only be called after get{pw,sp}ent()
Calling them unconditionally can result in memory corruption.
-rw-r--r--slock.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/slock.c b/slock.c
index 399386b..d281965 100644
--- a/slock.c
+++ b/slock.c
@@ -73,7 +73,6 @@ getpw(void) { /* only run as root */
73 else 73 else
74 die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n"); 74 die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
75 } 75 }
76 endpwent();
77 rval = pw->pw_passwd; 76 rval = pw->pw_passwd;
78 77
79#if HAVE_SHADOW_H 78#if HAVE_SHADOW_H
@@ -82,7 +81,6 @@ getpw(void) { /* only run as root */
82 sp = getspnam(getenv("USER")); 81 sp = getspnam(getenv("USER"));
83 if(!sp) 82 if(!sp)
84 die("slock: cannot retrieve shadow entry (make sure to suid or sgid slock)\n"); 83 die("slock: cannot retrieve shadow entry (make sure to suid or sgid slock)\n");
85 endspent();
86 rval = sp->sp_pwdp; 84 rval = sp->sp_pwdp;
87 } 85 }
88#endif 86#endif