Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Nov 2012 17:30:30 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Eitan Adler <eadler@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r243076 - head/usr.sbin/chkgrp
Message-ID:  <20121115153030.GD73505@kib.kiev.ua>
In-Reply-To: <201211151506.qAFF63v0003848@svn.freebsd.org>
References:  <201211151506.qAFF63v0003848@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--vAuP2vENPacJU4tn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Nov 15, 2012 at 03:06:03PM +0000, Eitan Adler wrote:
> Author: eadler
> Date: Thu Nov 15 15:06:03 2012
> New Revision: 243076
> URL: http://svnweb.freebsd.org/changeset/base/243076
>=20
> Log:
>   Check the range of the gid
>  =20
>   Approved by:	cperciva
>   MFC after:	1 week
>=20
> Modified:
>   head/usr.sbin/chkgrp/chkgrp.c
>=20
> Modified: head/usr.sbin/chkgrp/chkgrp.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/usr.sbin/chkgrp/chkgrp.c	Thu Nov 15 15:06:00 2012	(r243075)
> +++ head/usr.sbin/chkgrp/chkgrp.c	Thu Nov 15 15:06:03 2012	(r243076)
> @@ -30,7 +30,10 @@
>  __FBSDID("$FreeBSD$");
> =20
>  #include <err.h>
> +#include <errno.h>
>  #include <ctype.h>
> +#include <limits.h>
> +#include <stdint.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> @@ -150,6 +153,18 @@ main(int argc, char *argv[])
>  	    warnx("%s: line %d: GID is not numeric", gfn, n);
>  	    e++;
>  	}
> +
> +	/* check the range of the group id */
> +	errno =3D 0;
> +	unsigned long groupid =3D strtoul(f[2], NULL, 10);
And this violates style.
The checks for strtoul failure are not exhaustive.

> +	if (errno !=3D 0) {
> +		warnx("%s: line %d: strtoul failed", gfn, n);
> +	}
> +	else if (groupid > GID_MAX) {
> +		warnx("%s: line %d: group id is too large (> %ju)",
> +		  gfn, n, (uintmax_t)GID_MAX);
> +		e++;
> +	}
>  =09
>  #if 0
>  	/* entry is correct, so print it */

--vAuP2vENPacJU4tn
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iEYEARECAAYFAlClCpYACgkQC3+MBN1Mb4h+UQCdFCogE7/C8sllwbqEsB/TQcRG
UFUAoJql4ZcK0jdkFsz/tt04dhITk6Bu
=bXBb
-----END PGP SIGNATURE-----

--vAuP2vENPacJU4tn--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121115153030.GD73505>