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
This commit is contained in:
Neels Hofmeyr 2017-11-10 16:59:49 +01:00 committed by Harald Welte
parent c82e6ad190
commit 8db490695d
1 changed files with 6 additions and 0 deletions

View File

@ -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)