From nobody  Tue Oct 27 13:15:54 1998
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id NAA24806;
          Tue, 27 Oct 1998 13:15:54 -0800 (PST)
          (envelope-from nobody)
Message-Id: <199810272115.NAA24806@hub.freebsd.org>
Date: Tue, 27 Oct 1998 13:15:54 -0800 (PST)
From: rich@math.missouri.edu
To: freebsd-gnats-submit@freebsd.org
Subject: '#' comments in /etc/group mishandled
X-Send-Pr-Version: www-1.0

>Number:         8467
>Category:       misc
>Synopsis:       '#' comments in /etc/group mishandled
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 27 13:20:00 PST 1998
>Closed-Date:    Tue Oct 27 16:04:07 PST 1998
>Last-Modified:  Tue Oct 27 16:04:58 PST 1998
>Originator:     Richard Winkel
>Release:        2.2.7-STABLE
>Organization:
Univ. of MO
>Environment:
FreeBSD roadster.math.missouri.edu 2.2.7-STABLE FreeBSD 2.2.7-STABLE #0:
Thu Oct 15 21:17:36 CDT 1998
root@roadster.math.missouri.edu:/usr/src/sys/compile/g6_sd0  i386

>Description:
grscan() in /usr/src/lib/libc/gen/getgrent.c has no special
handling for comment lines, so, for instance, the line:
#       $Id: group,v 1.13.2.4 1998/09/13 23:10:08 brian Exp $
is treated as an entry for group with gid=10, 
gname="#       $Id: group,v 1.13.2.4 1998/09/13 23" .
Although there's nothing in the group(5) man page about comments,
such handling would be in keeping with the passwd(5) convention
as well as most every other unix config file.

>How-To-Repeat:
With above comment line in /etc/group:
touch /tmp/whatever
chown root.10 /tmp/whatever
ls -l /tmp/whatever
-rw-r--r--  1 root  #          0 Oct 27 14:50 whatever

>Fix:
In /usr/src/lib/libc/gen/getgrent.c, around line 231:

                /* skip lines that are too big */
                if (!index(line, '\n')) {
                        int ch; 
                                        
                        while ((ch = getc(_gr_fp)) != '\n' && ch != EOF)
                                ;
                        continue;               
                }
+               if (*bp=='#') continue; /* skip comment lines */
                if ((_gr_group.gr_name = strsep(&bp, ":\n")) == NULL) {

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: brian 
State-Changed-When: Tue Oct 27 16:04:07 PST 1998 
State-Changed-Why:  
Fixed in getgrent.c v 1.12.2.3 (it now ignores blank lines and lines 
starting with # as in -current). 
>Unformatted:
