diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2017-11-10 16:59:49 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-11-12 14:22:00 +0000 |
commit | 8db490695d2bc9c08199c4073b01d79f72158c85 (patch) | |
tree | bbffd04d2ca62a0dd9ba403830a2f85fb394ea07 | |
parent | c82e6ad190cd03354306bca218bf1f530b0a3150 (diff) |
db-tool: error-exit on too many arguments
Each arg parsing should increment optind, so if there are any surplus args in
the end, that's an error.
Change-Id: I9fc0a87d11db8c35061568e3f8b5a5547931a961
-rw-r--r-- | src/hlr_db_tool.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/hlr_db_tool.c b/src/hlr_db_tool.c index fb10f3e..d8a3584 100644 --- a/src/hlr_db_tool.c +++ b/src/hlr_db_tool.c @@ -159,6 +159,12 @@ static void handle_options(int argc, char **argv) print_help(); exit(EXIT_FAILURE); } + + if (argc - optind > 0) { + fprintf(stderr, "Too many arguments: '%s'\n", argv[optind]); + print_help(); + exit(EXIT_FAILURE); + } } static void signal_hdlr(int signal) |