[PATCH 1/2] Set errno to 0 before getpwuid() and check it afterwards

From: sin <sin_AT_2f30.org>
Date: Thu, 14 Nov 2013 11:24:08 +0000

---
 slock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
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\n", strerror(errno));
+	else if (!pw)
 		die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
 	endpwent();
 	rval =  pw->pw_passwd;
-- 
1.8.4.2
--7JfCtLOvnd9MIVvH--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Thu Nov 14 2013 - 13:36:03 CET