summaryrefslogtreecommitdiffstats
path: root/usr.sbin/chkgrp
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2012-11-15 15:06:24 +0000
committereadler <eadler@FreeBSD.org>2012-11-15 15:06:24 +0000
commit2870d7badbaa8a19ad288c1530c39f7bd4dc4020 (patch)
tree08a1ea23b30dbeecf9b02b8ee4b2ab9c5bc63053 /usr.sbin/chkgrp
parenta3bf527f51a280bda9086aa025f54348fd4a619a (diff)
downloadFreeBSD-src-2870d7badbaa8a19ad288c1530c39f7bd4dc4020.zip
FreeBSD-src-2870d7badbaa8a19ad288c1530c39f7bd4dc4020.tar.gz
Be declarative about if an error has occured.
Fixes overflow on very large group files with lots of errors. This is unlikely to occur in practice. Approved by: cperciva MFC after: 1 week
Diffstat (limited to 'usr.sbin/chkgrp')
-rw-r--r--usr.sbin/chkgrp/chkgrp.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.sbin/chkgrp/chkgrp.c b/usr.sbin/chkgrp/chkgrp.c
index fa4b701..82fa866 100644
--- a/usr.sbin/chkgrp/chkgrp.c
+++ b/usr.sbin/chkgrp/chkgrp.c
@@ -81,7 +81,7 @@ main(int argc, char *argv[])
break;
if (len > 0 && line[len - 1] != '\n') {
warnx("%s: line %d: no newline character", gfn, n);
- e++;
+ e = 1;
}
while (len && isspace(line[len-1]))
len--;
@@ -114,14 +114,14 @@ main(int argc, char *argv[])
warnx("%s: line %d: missing field(s)", gfn, n);
for ( ; k < 4; k++)
f[k] = empty;
- e++;
+ e = 1;
}
for (cp = f[0] ; *cp ; cp++) {
if (!isalnum(*cp) && *cp != '.' && *cp != '_' && *cp != '-' &&
(cp > f[0] || *cp != '+')) {
warnx("%s: line %d: '%c' invalid character", gfn, n, *cp);
- e++;
+ e = 1;
}
}
@@ -129,14 +129,14 @@ main(int argc, char *argv[])
if (!isalnum(*cp) && *cp != '.' && *cp != '_' && *cp != '-' &&
*cp != ',') {
warnx("%s: line %d: '%c' invalid character", gfn, n, *cp);
- e++;
+ e = 1;
}
}
/* check if fourth field ended with a colon */
if (i < len) {
warnx("%s: line %d: too many fields", gfn, n);
- e++;
+ e = 1;
}
/* check that none of the fields contain whitespace */
@@ -144,14 +144,14 @@ main(int argc, char *argv[])
if (strcspn(f[k], " \t") != strlen(f[k])) {
warnx("%s: line %d: field %d contains whitespace",
gfn, n, k+1);
- e++;
+ e = 1;
}
}
/* check that the GID is numeric */
if (strspn(f[2], "0123456789") != strlen(f[2])) {
warnx("%s: line %d: GID is not numeric", gfn, n);
- e++;
+ e = 1;
}
/* check the range of the group id */
@@ -163,7 +163,7 @@ main(int argc, char *argv[])
else if (groupid > GID_MAX) {
warnx("%s: line %d: group id is too large (> %ju)",
gfn, n, (uintmax_t)GID_MAX);
- e++;
+ e = 1;
}
#if 0
OpenPOWER on IntegriCloud