summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2002-10-10 17:11:20 +0000
committergreen <green@FreeBSD.org>2002-10-10 17:11:20 +0000
commit8d1b432ebca11727add6494b7b74e57979cf4a44 (patch)
tree618aa591b2c3f77d0907e9ce1eb690de711a3717 /usr.sbin
parent919bffa046a021ee536b394fbe122651a8e56421 (diff)
downloadFreeBSD-src-8d1b432ebca11727add6494b7b74e57979cf4a44.zip
FreeBSD-src-8d1b432ebca11727add6494b7b74e57979cf4a44.tar.gz
Correct argc verification (don't crash).
Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/extattr/rmextattr.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/extattr/rmextattr.c b/usr.sbin/extattr/rmextattr.c
index 40f9e96..13bebc6 100644
--- a/usr.sbin/extattr/rmextattr.c
+++ b/usr.sbin/extattr/rmextattr.c
@@ -102,7 +102,8 @@ main(int argc, char *argv[])
char *buf, *visbuf, *p;
const char *options, *attrname;
- int buflen, visbuflen, ch, error, i, arg_counter, attrnamespace;
+ int buflen, visbuflen, ch, error, i, arg_counter, attrnamespace,
+ minargc;
int flag_force = 0;
int flag_nofollow = 0;
@@ -119,15 +120,19 @@ main(int argc, char *argv[])
if (!strcmp(p, "getextattr")) {
what = EAGET;
options = "fhqsx";
+ minargc = 3;
} else if (!strcmp(p, "setextattr")) {
what = EASET;
options = "fhq";
+ minargc = 4;
} else if (!strcmp(p, "rmextattr")) {
what = EARM;
options = "fhq";
+ minargc = 3;
} else if (!strcmp(p, "lsextattr")) {
what = EALS;
options = "fhq";
+ minargc = 2;
} else {
usage();
}
@@ -158,7 +163,7 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (argc < 2)
+ if (argc < minargc)
usage();
error = extattr_string_to_namespace(argv[0], &attrnamespace);
OpenPOWER on IntegriCloud