Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/httpd avoid an impossible case the compiler can't qu...



details:   https://anonhg.NetBSD.org/src/rev/a458a8a89d6e
branches:  trunk
changeset: 346186:a458a8a89d6e
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu Jun 30 13:17:48 2016 +0000

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

diffstat:

 libexec/httpd/bozohttpd.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (34 lines):

diff -r 8d17b466a146 -r a458a8a89d6e libexec/httpd/bozohttpd.c
--- a/libexec/httpd/bozohttpd.c Thu Jun 30 12:57:35 2016 +0000
+++ b/libexec/httpd/bozohttpd.c Thu Jun 30 13:17:48 2016 +0000
@@ -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 @@
        extern char     **environ;
        static char      *cleanenv[1] = { NULL };
        uid_t             uid;
+       int               uidset = 0;
        char             *chrootdir;
        char             *username;
        char             *portnum;
@@ -2339,6 +2340,7 @@
                        bozoerr(httpd, 1, "setgid(%u): %s", pw->pw_gid,
                                strerror(errno));
                uid = pw->pw_uid;
+               uidset = 1;
        }
        /*
         * handle chroot.
@@ -2353,7 +2355,7 @@
                                strerror(errno));
        }
 
-       if (username != NULL && setuid(uid) == -1)
+       if (uidset && setuid(uid) == -1)
                bozoerr(httpd, 1, "setuid(%d): %s", uid, strerror(errno));
 
        /*



Home | Main Index | Thread Index | Old Index