diff options
author | cperciva <cperciva@FreeBSD.org> | 2005-08-25 17:01:06 +0000 |
---|---|---|
committer | cperciva <cperciva@FreeBSD.org> | 2005-08-25 17:01:06 +0000 |
commit | cb19e170f1293ef93f13ddf4c82228e29304662d (patch) | |
tree | 934fa90619ceb6fd5a4bc7cdf4330efb3f8c698d /usr.sbin/chkgrp | |
parent | a8fb9abe899a9599f5f74616a31642cbc8b1b089 (diff) | |
download | FreeBSD-src-cb19e170f1293ef93f13ddf4c82228e29304662d.zip FreeBSD-src-cb19e170f1293ef93f13ddf4c82228e29304662d.tar.gz |
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
Diffstat (limited to 'usr.sbin/chkgrp')
-rw-r--r-- | usr.sbin/chkgrp/chkgrp.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/chkgrp/chkgrp.c b/usr.sbin/chkgrp/chkgrp.c index 635ec8f..eca26af 100644 --- a/usr.sbin/chkgrp/chkgrp.c +++ b/usr.sbin/chkgrp/chkgrp.c @@ -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); |