diff options
author | Moritz Jodeit <moritz@cvs.openbsd.org> | 2007-05-17 11:01:37 +0000 |
---|---|---|
committer | Moritz Jodeit <moritz@cvs.openbsd.org> | 2007-05-17 11:01:37 +0000 |
commit | cbd309e77fc41340ffd6f8e839ebece2430d0060 (patch) | |
tree | aa267c94adaceee03576c27cf8fa480e8cd6acb3 /usr.bin | |
parent | 97aedd1c637976a04e74ce2ce2dea1c6ce21e11d (diff) |
Check getpwnam() return value for NULL before dereferencing it.
ok ray@ millert@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sup/src/supcmisc.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/sup/src/supcmisc.c b/usr.bin/sup/src/supcmisc.c index 36e427e69d5..a98344c473e 100644 --- a/usr.bin/sup/src/supcmisc.c +++ b/usr.bin/sup/src/supcmisc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: supcmisc.c,v 1.15 2003/04/15 07:21:09 deraadt Exp $ */ +/* $OpenBSD: supcmisc.c,v 1.16 2007/05/17 11:00:37 moritz Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -249,12 +249,13 @@ ugconvert(uname, gname, uid, gid, mode) *gid = gr->gr_gid; return; } - if (pw == NULL) - pw = getpwnam(uname); + if (pw == NULL && (pw = getpwnam(uname)) == NULL) + goto defids; *mode &= ~S_ISGID; *gid = pw->pw_gid; return; } +defids: *mode &= ~(S_ISUID|S_ISGID); if (defuid != UID_MAX) { *uid = defuid; |