From bdad16fdda407c6e27977290f2c3267d0881d017 Mon Sep 17 00:00:00 2001 From: wpaul Date: Sat, 29 Apr 1995 17:14:50 +0000 Subject: 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.) --- lib/libc/gen/getgrent.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/libc') 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"))) -- cgit v1.1