~ob/slock

6a5512835485ac501d983161ca15b311a95c5649 — sin 7 years ago ba3acfc
Set errno to 0 before getpwuid() and check it afterwards
1 files changed, 4 insertions(+), 1 deletions(-)

M slock.c
M slock.c => slock.c +4 -1
@@ 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;