summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getgrent.c
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1995-04-29 17:14:50 +0000
committerwpaul <wpaul@FreeBSD.org>1995-04-29 17:14:50 +0000
commitbdad16fdda407c6e27977290f2c3267d0881d017 (patch)
tree5405997cc95c1fb32e7b22a07f6dda630180db24 /lib/libc/gen/getgrent.c
parentdd621033643f29855970bcad654fe536cb4583b2 (diff)
downloadFreeBSD-src-bdad16fdda407c6e27977290f2c3267d0881d017.zip
FreeBSD-src-bdad16fdda407c6e27977290f2c3267d0881d017.tar.gz
Small fix for the following problems:
- If you take the wheel entry out of /etc/group and turn on NIS, the '+:*::' line is incorrectly flagged as the entry for wheel (the empty gid section is translated to 0), hence getgrgid() returns '+' as the name of the group instead of 'wheel.' - Using just '+:' as the 'turn on NIS' switch in /etc/group makes getgrgid() dump core because of a null pointer dereference. (Last time I was in here, I foolishly assumed that fixing the core dump problems with getgrnam() and getgrent() would fix getgrgid() too. Silly me.)
Diffstat (limited to 'lib/libc/gen/getgrent.c')
-rw-r--r--lib/libc/gen/getgrent.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index 8c60361..a13e7c3 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -239,8 +239,16 @@ grscan(search, gid, name)
* past this point under certain circumstances or
* we risk dereferencing null pointers down below.
*/
- if (!search && _gr_group.gr_name[0] == '+')
- return(1);
+ if (_gr_group.gr_name[0] == '+') {
+ switch(search) {
+ case 0:
+ return(1);
+ case 1:
+ return(0);
+ default:
+ return(0);
+ }
+ }
#endif /* YP */
_gr_group.gr_passwd = strsep(&bp, ":\n");
if (!(cp = strsep(&bp, ":\n")))
OpenPOWER on IntegriCloud