Date: Tue, 22 Apr 2003 00:00:12 -0700 (PDT) From: Peter Pentchev <roam@ringlet.net> To: freebsd-bugs@FreeBSD.org Subject: Re: conf/51256: chkgrp should make sure the file is newline terminated Message-ID: <200304220700.h3M70CM3058589@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR conf/51256; it has been noted by GNATS. 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--;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304220700.h3M70CM3058589>