Date: Tue, 27 May 2003 11:42:42 +0300 From: Peter Pentchev <roam@ringlet.net> To: audit@FreeBSD.org Subject: Re: conf/51256: chkgrp should make sure the file is newline terminated Message-ID: <20030527084242.GB513@straylight.oblivion.bg> In-Reply-To: <200304220700.h3M70CM3058589@freefall.freebsd.org> References: <200304220700.h3M70CM3058589@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Tue, Apr 22, 2003 at 12:00:12AM -0700, I wrote:
> 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.
Could somebody take a look at this PR and the patch (quoted below), and
see if there's anything wrong with it or it may be committed?
> 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--;
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
"yields falsehood, when appended to its quotation." yields falsehood, when appended to its quotation.
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)
iD8DBQE+0yUC7Ri2jRYZRVMRAhEoAKCIYWEfDVMmc/W0X9vqr4bM1d3urgCgk7OT
J0SnrM/LrqjwUk+rpKQh2O0=
=zsD7
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030527084242.GB513>
