aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2012-11-15 15:06:03 +0000
committerEitan Adler <eadler@FreeBSD.org>2012-11-15 15:06:03 +0000
commit2ad87454e2b4c521ede163794485a79af88d30b7 (patch)
tree8a45defd3b9e111ab8da66c4d4e4e0029975c45b /usr.sbin
parentac1e7ba236ae7e211a27a93e6d9c013b76da32c4 (diff)
downloadsrc-2ad87454e2b4c521ede163794485a79af88d30b7.tar.gz
src-2ad87454e2b4c521ede163794485a79af88d30b7.zip
Check the range of the gid
Approved by: cperciva MFC after: 1 week
Notes
Notes: svn path=/head/; revision=243076
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/chkgrp/chkgrp.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/usr.sbin/chkgrp/chkgrp.c b/usr.sbin/chkgrp/chkgrp.c
index ac40ed586e09..2dd41a881a05 100644
--- a/usr.sbin/chkgrp/chkgrp.c
+++ b/usr.sbin/chkgrp/chkgrp.c
@@ -30,7 +30,10 @@
__FBSDID("$FreeBSD$");
#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 = 0;
+ unsigned long groupid = strtoul(f[2], NULL, 10);
+ if (errno != 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++;
+ }
#if 0
/* entry is correct, so print it */