From 8af6568ddd24af3aab97ddb3d6d4c3445f271c7e Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Mon, 1 Aug 2016 23:18:29 +0200 Subject: [PATCH] UPSTREAM: cbfstool: Check for excessive arguments BUG=None BRANCH=None TEST=None Change-Id: Iad198c957d171389dc3454f15dd0ad743425354d Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/16019 Tested-by: build bot (Jenkins) Reviewed-by: Omar Pakker Reviewed-by: Paul Menzel Reviewed-by: Stefan Reinauer Reviewed-on: https://chromium-review.googlesource.com/367389 Commit-Ready: Furquan Shaikh Tested-by: Furquan Shaikh Reviewed-by: Furquan Shaikh --- util/cbfstool/cbfstool.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index e1bdf2f71a..e70cb4b0b8 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -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) {