MFC revision 1.11: Fix a bug introduced in revision 1.9 which causes

chkgrp to coredump on certain corrupt files.

Approved by:	re (scottl)
This commit is contained in:
cperciva 2005-10-03 21:39:21 +00:00
parent 22426a09ff
commit 571f9d1571

View File

@ -36,6 +36,8 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <sysexits.h>
static char empty[] = { 0 };
static void
usage(void)
{
@ -105,6 +107,13 @@ main(int argc, char *argv[])
line[i++] = 0;
}
if (k < 4) {
warnx("%s: line %d: missing field(s)", gfn, n);
for ( ; k < 4; k++)
f[k] = empty;
e++;
}
for (cp = f[0] ; *cp ; cp++) {
if (!isalnum(*cp) && *cp != '.' && *cp != '_' && *cp != '-' &&
(cp > f[0] || *cp != '+')) {
@ -121,11 +130,6 @@ main(int argc, char *argv[])
}
}
if (k < 4) {
warnx("%s: line %d: missing field(s)", gfn, n);
e++;
}
/* check if fourth field ended with a colon */
if (i < len) {
warnx("%s: line %d: too many fields", gfn, n);