[hackers] [slock] Only check errno if getpwuid() fails || sin

From: <git_AT_suckless.org>
Date: Wed, 09 Jul 2014 15:42:28 +0200

commit 8745098fa440ef3bf1d8e173dcd91514b34600c6
Author: sin <sin_AT_2f30.org>
Date: Wed Jul 9 14:40:49 2014 +0100

    Only check errno if getpwuid() fails
    
    Checking errno otherwise is unspecified.

diff --git a/slock.c b/slock.c
index aedee2e..399386b 100644
--- a/slock.c
+++ b/slock.c
_AT_@ -67,10 +67,12 @@ getpw(void) { /* only run as root */
 
         errno = 0;
         pw = getpwuid(getuid());
- if (errno)
- die("slock: getpwuid: %s
", strerror(errno));
- else if (!pw)
- die("slock: cannot retrieve password entry (make sure to suid or sgid slock)
");
+ if (!pw) {
+ if (errno)
+ die("slock: getpwuid: %s
", strerror(errno));
+ else
+ die("slock: cannot retrieve password entry (make sure to suid or sgid slock)
");
+ }
         endpwent();
         rval = pw->pw_passwd;
 
Received on Wed Jul 09 2014 - 15:42:28 CEST

This archive was generated by hypermail 2.3.0 : Wed Jul 09 2014 - 15:48:08 CEST