Fix a bug introduced in revision 1.9 which causes chkgrp to coredump on
certain corrupt files. Submitted by: liamfoy@dragonflybsd.org Reported by: Nikolay Kalev, via freebsd-current MFC after: 3 days
This commit is contained in:
parent
f41317de66
commit
a2c16fbcd0
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user