Re: conf/51256: chkgrp should make sure the file is newline terminated
Peter Pentchev <[email protected]> Tue, 27 May 2003 11:42:42 +0300
| Newsgroups | gmane.os.freebsd.devel.audit |
|---|---|
| Message-ID | <[email protected]> |
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 [email protected] [email protected] [email protected]
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.
signature.asc
(application/pgp-signature, 187 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQE+0yUC7Ri2jRYZRVMRAhEoAKCIYWEfDVMmc/W0X9vqr4bM1d3urgCgk7OT J0SnrM/LrqjwUk+rpKQh2O0= =zsD7 -----END PGP SIGNATURE-----