Subject: lib/415: Programs that access the netgroup file may crash
To: None <gnats-admin>
From: None <grossman@informatik.tu-muenchen.de>
List: netbsd-bugs
Date: 08/15/1994 12:20:07
>Number:         415
>Category:       lib
>Synopsis:       Programs that access the netgroup file may crash
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 15 12:20:05 1994
>Originator:     Rolf Grossmann
>Organization:
Technische Universitaet Muenchen
>Release:        NetBSD 1.0_BETA
>Environment:
System: NetBSD flip 1.0_BETA NetBSD 1.0_BETA (TIGKI) #38: Fri Aug 12 16:44:36 MET DST 1994 grossman@flip:/usr/src/sys/arch/sparc/compile/TIGKI sparc


>Description:
	There is a bug in libc/gen/getnetgrent.c, that causes programs using
	netgroups to crash, if the file /etc/netgroup exists and contains a 
	line that references another netgroup at the and of the line. 
	(Just see the How-To-Repeat section ;))

>How-To-Repeat:
	Put this in your /etc/netgroup file:
# demonstration netgroup file (next line causes the problem)
realgroup demogroup
demogroup (host,user,dom)

	Take any program that uses netgroups (e.g. mountd) or write your
	own like:
int main()
{
        extern int setnetgrent();

        setnetgrent("realgroup");
        return 0;
}
	

>Fix:
	Quite easy. Here's the patch:
	
*** gen/getnetgrent.c.orig      Mon Aug 15 20:08:00 1994
--- gen/getnetgrent.c   Mon Aug 15 20:30:04 1994
***************
*** 249,254 ****
--- 249,256 ----
                        if (parse_netgrp(spos))
                                return (1);
                }
+               if (pos == NULL)
+                       break;
                while (*pos == ' ' || *pos == ',' || *pos == '\t')
                        pos++;
        }

	By the way: This just fixes the misbehaviour, when the syntax is
	correct. It's still possible to write an incorrect netgroup file 
	that causes programs to crash.
>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------