[hackers] [slock] Set errno to 0 before getpwuid() and check it afterwards || sin

From: <git_AT_suckless.org>
Date: Wed, 29 Jan 2014 15:19:49 +0100

commit 6a5512835485ac501d983161ca15b311a95c5649
Author: sin <sin_AT_2f30.org>
Date: Thu Nov 14 11:24:08 2013 +0000

    Set errno to 0 before getpwuid() and check it afterwards

diff --git a/slock.c b/slock.c
index 467937c..506231e 100644
--- a/slock.c
+++ b/slock.c
_AT_@ -65,8 +65,11 @@ getpw(void) { /* only run as root */
         const char *rval;
         struct passwd *pw;
 
+ errno = 0;
         pw = getpwuid(getuid());
- if(!pw)
+ if (errno)
+ die("slock: getpwuid: %s
", strerror(errno));
+ else if (!pw)
                 die("slock: cannot retrieve password entry (make sure to suid or sgid slock)
");
         endpwent();
         rval = pw->pw_passwd;
Received on Wed Jan 29 2014 - 15:19:49 CET

This archive was generated by hypermail 2.3.0 : Wed Jan 29 2014 - 15:24:09 CET