Module Name:    src
Committed By:   mrg
Date:           Thu Jun 30 13:17:48 UTC 2016

Modified Files:
        src/libexec/httpd: bozohttpd.c

Log Message:
avoid an impossible case the compiler can't quite tell.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/libexec/httpd/bozohttpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/httpd/bozohttpd.c
diff -u src/libexec/httpd/bozohttpd.c:1.81 src/libexec/httpd/bozohttpd.c:1.82
--- src/libexec/httpd/bozohttpd.c:1.81	Tue May 24 21:18:29 2016
+++ src/libexec/httpd/bozohttpd.c	Thu Jun 30 13:17:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bozohttpd.c,v 1.81 2016/05/24 21:18:29 agc Exp $	*/
+/*	$NetBSD: bozohttpd.c,v 1.82 2016/06/30 13:17:48 mrg Exp $	*/
 
 /*	$eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $	*/
 
@@ -2244,6 +2244,7 @@ bozo_setup(bozohttpd_t *httpd, bozoprefs
 	extern char	**environ;
 	static char	 *cleanenv[1] = { NULL };
 	uid_t		  uid;
+	int		  uidset = 0;
 	char		 *chrootdir;
 	char		 *username;
 	char		 *portnum;
@@ -2339,6 +2340,7 @@ bozo_setup(bozohttpd_t *httpd, bozoprefs
 			bozoerr(httpd, 1, "setgid(%u): %s", pw->pw_gid,
 				strerror(errno));
 		uid = pw->pw_uid;
+		uidset = 1;
 	}
 	/*
 	 * handle chroot.
@@ -2353,7 +2355,7 @@ bozo_setup(bozohttpd_t *httpd, bozoprefs
 				strerror(errno));
 	}
 
-	if (username != NULL && setuid(uid) == -1)
+	if (uidset && setuid(uid) == -1)
 		bozoerr(httpd, 1, "setuid(%d): %s", uid, strerror(errno));
 
 	/*

Reply via email to