From bdg730@makserver0.usask.ca  Mon Apr 21 15:58:53 2003
Return-Path: <bdg730@makserver0.usask.ca>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7EA8637B401
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 21 Apr 2003 15:58:53 -0700 (PDT)
Received: from makserver0.usask.ca (makserver0.usask.ca [128.233.128.254])
	by mx1.FreeBSD.org (Postfix) with ESMTP id CC05043FE3
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 21 Apr 2003 15:58:52 -0700 (PDT)
	(envelope-from bdg730@makserver0.usask.ca)
Received: from makserver0.usask.ca (localhost.usask.ca [127.0.0.1])
	by makserver0.usask.ca (8.12.6/8.12.6) with ESMTP id h3LMwoRK000449
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 21 Apr 2003 16:58:50 -0600 (CST)
	(envelope-from bdg730@makserver0.usask.ca)
Received: (from root@localhost)
	by makserver0.usask.ca (8.12.6/8.12.6/Submit) id h3LKmloI002492;
	Mon, 21 Apr 2003 14:48:47 -0600 (CST)
Message-Id: <200304212048.h3LKmloI002492@makserver0.usask.ca>
Date: Mon, 21 Apr 2003 14:48:47 -0600 (CST)
From: Brian D Gallaway <bdg730@makserver0.usask.ca>
Reply-To: Brian D Gallaway <bdg730@makserver0.usask.ca>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: chkgrp should make sure the file is newline terminated	
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         51256
>Category:       conf
>Synopsis:       chkgrp should make sure the file is newline terminated
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 21 16:00:32 PDT 2003
>Closed-Date:    Mon Jun 23 04:29:56 PDT 2003
>Last-Modified:  Mon Jun 23 04:29:56 PDT 2003
>Originator:     Brian D Gallaway
>Release:        FreeBSD 5.0-RELEASE i386
>Organization:
University of Saskatchewan	
>Environment:
System: FreeBSD makserver0.usask.ca 5.0-RELEASE FreeBSD 5.0-RELEASE #0: Thu Jan 16 22:16:53 GMT 2003 root@hollin.btc.adaptec.com:/usr/obj/usr/src/sys/GENERIC i386


	
>Description:
	The chkgrp command does not detect when there is not a newline at the end of the file.  If the /etc/group file is not newline terminated, the /etc/group file's last entry will not be used.  This is an error that could easily be checked for in chkgrp.  
>How-To-Repeat:
	see above
>Fix:
        have chkgrp warn the user if no newline is found at the end of /etc/group	



>Release-Note:
>Audit-Trail:

From: Peter Pentchev <roam@ringlet.net>
To: Brian D Gallaway <bdg730@makserver0.usask.ca>
Cc: bug-followup@FreeBSD.org
Subject: Re: conf/51256: chkgrp should make sure the file is newline terminated
Date: Tue, 22 Apr 2003 09:49:57 +0300

 On Mon, Apr 21, 2003 at 02:48:47PM -0600, Brian D Gallaway wrote:
 > 
 > >Number:         51256
 > >Category:       conf
 > >Synopsis:       chkgrp should make sure the file is newline terminated
 > >Originator:     Brian D Gallaway
 > >Release:        FreeBSD 5.0-RELEASE i386
 > >Description:
 > 	The chkgrp command does not detect when there is not a newline at the end of the file.  If the /etc/group file is not newline terminated, the /etc/group file's last entry will not be used.  This is an error that could easily be checked for in chkgrp.  
 > >How-To-Repeat:
 > 	see above
 > >Fix:
 >         have chkgrp warn the user if no newline is found at the end of /etc/group	
 
 The attached trivial patch should do the trick.
 
 G'luck,
 Peter
 
 -- 
 Peter Pentchev	roam@ringlet.net    roam@sbnd.net    roam@FreeBSD.org
 PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
 Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
 This sentence was in the past tense.
 
 Index: src/usr.sbin/chkgrp/chkgrp.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/chkgrp/chkgrp.c,v
 retrieving revision 1.6
 diff -u -r1.6 chkgrp.c
 --- src/usr.sbin/chkgrp/chkgrp.c	3 Jul 2001 21:40:34 -0000	1.6
 +++ src/usr.sbin/chkgrp/chkgrp.c	22 Apr 2003 06:46:33 -0000
 @@ -76,6 +76,10 @@
      while (++n) {
  	if ((line = fgetln(gf, &len)) == NULL)
  	    break;
 +	if (len > 0 && line[len - 1] != '\n' && line[len - 1] != '\r') {
 +	    warnx("%s: line %d: no newline character", gfn, n);
 +	    e++;
 +	}
  	while (len && isspace(line[len-1]))
  	    len--;
  
State-Changed-From-To: open->patched 
State-Changed-By: roam 
State-Changed-When: Fri Jun 6 00:09:28 PDT 2003 
State-Changed-Why:  
The fix was committed to -current, I will MFC it in two weeks or so. 
Thanks for the problem report! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=51256 
State-Changed-From-To: patched->closed 
State-Changed-By: roam 
State-Changed-When: Mon Jun 23 04:29:39 PDT 2003 
State-Changed-Why:  
Fix merged into -STABLE.  Thanks for the problem report! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=51256 
>Unformatted:
