conf/51256: chkgrp should make sure the file is newline
terminated
Peter Pentchev
roam at ringlet.net
Tue May 27 01:45:41 PDT 2003
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 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
"yields falsehood, when appended to its quotation." yields falsehood, when appended to its quotation.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-audit/attachments/20030527/fc91f371/attachment.bin
More information about the freebsd-audit
mailing list