aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-11-10 16:59:49 +0100
committerHarald Welte <laforge@gnumonks.org>2017-11-12 14:22:00 +0000
commit8db490695d2bc9c08199c4073b01d79f72158c85 (patch)
treebbffd04d2ca62a0dd9ba403830a2f85fb394ea07
parentc82e6ad190cd03354306bca218bf1f530b0a3150 (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.c6
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)