conf/51256: chkgrp should make sure the file is newline
terminated
Peter Pentchev
roam at ringlet.net
Tue Apr 22 00:00:13 PDT 2003
The following reply was made to PR conf/51256; it has been noted by GNATS.
From: Peter Pentchev <roam at ringlet.net>
To: Brian D Gallaway <bdg730 at makserver0.usask.ca>
Cc: bug-followup at 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 at ringlet.net roam at sbnd.net roam at 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--;
More information about the freebsd-bugs
mailing list