UPSTREAM: cbfstool: Check for excessive arguments

BUG=None
BRANCH=None
TEST=None

Change-Id: Iad198c957d171389dc3454f15dd0ad743425354d
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/16019
Tested-by: build bot (Jenkins)
Reviewed-by: Omar Pakker
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-on: https://chromium-review.googlesource.com/367389
Commit-Ready: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
Nico Huber 2016-08-01 23:18:29 +02:00 committed by chrome-bot
commit 8af6568ddd

View file

@ -1296,8 +1296,14 @@ int main(int argc, char **argv)
c = getopt_long(argc, argv, commands[i].optstring,
long_options, &option_index);
if (c == -1)
if (c == -1) {
if (optind < argc) {
ERROR("%s: excessive argument -- '%s'"
"\n", argv[0], argv[optind]);
return 1;
}
break;
}
/* filter out illegal long options */
if (strchr(commands[i].optstring, c) == NULL) {