diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2016-02-05 12:15:16 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2016-02-05 12:15:16 +0000 |
commit | a2a2afd4b4279daaba0647a27cc42dbff4b234df (patch) | |
tree | 1379f78bdfc3ef2af53ae0e5419b96f8c37b9056 | |
parent | e9772fcb0a0669a80dfbec5c5f44f41bd9b08458 (diff) |
Bail out if an unknown option is passed.
There is no reason for rtadvd to be different from other daemons.
Input from and ok bluhm@ florian@
-rw-r--r-- | usr.sbin/rtadvd/rtadvd.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c index b3b411057a4..5375c9b2416 100644 --- a/usr.sbin/rtadvd/rtadvd.c +++ b/usr.sbin/rtadvd/rtadvd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtadvd.c,v 1.61 2015/12/01 12:11:31 jca Exp $ */ +/* $OpenBSD: rtadvd.c,v 1.62 2016/02/05 12:15:15 jca Exp $ */ /* $KAME: rtadvd.c,v 1.66 2002/05/29 14:18:36 itojun Exp $ */ /* @@ -130,7 +130,7 @@ u_int32_t ndopt_flags[] = { [ND_OPT_DNSSL] = NDOPT_FLAG_DNSSL, }; -int main(int, char *[]); +static __dead void usage(void); static void set_die(int); static void die(void); static void sock_open(void); @@ -162,9 +162,7 @@ main(int argc, char *argv[]) closefrom(3); /* get command line options and arguments */ -#define OPTIONS "c:ds" - while ((ch = getopt(argc, argv, OPTIONS)) != -1) { -#undef OPTIONS + while ((ch = getopt(argc, argv, "c:ds")) != -1) { switch (ch) { case 'c': conffile = optarg; @@ -175,16 +173,14 @@ main(int argc, char *argv[]) case 's': sflag = 1; break; + default: + usage(); } } argc -= optind; argv += optind; - if (argc == 0) { - fprintf(stderr, - "usage: rtadvd [-ds] [-c configfile] " - "interface ...\n"); - exit(1); - } + if (argc == 0) + usage(); SLIST_INIT(&ralist); @@ -278,6 +274,14 @@ main(int argc, char *argv[]) } static void +usage(void) +{ + fprintf(stderr, "usage: %s [-ds] [-c configfile] interface ...\n", + getprogname()); + exit(1); +} + +static void rtadvd_set_dump(int signo) { do_dump = 1; |