summaryrefslogtreecommitdiff
path: root/util/ectool
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2018-08-01 17:22:47 +0200
committerPatrick Georgi <pgeorgi@google.com>2018-08-02 21:55:27 +0000
commitcc7a411fc5a4e62c9211b882095ddde98640d63b (patch)
tree675112bd8cf5d8d8a620c45e5fb91a7b0d34f9b1 /util/ectool
parent8cd17eae2fca33671df544fe209a994105531e94 (diff)
downloadcoreboot-cc7a411fc5a4e62c9211b882095ddde98640d63b.tar.xz
util/ectool: Handle arguments more carefully
Check if an argument is given and if not print the usage. Check if all arguments are handled by getopt and if not print the usage. Change-Id: I40dbd2a51d018eb549e9b2fa4365b3e4f9355bff Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/27778 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Alexander Couzens <lynxis@fe80.eu> Reviewed-by: Evgeny Zinoviev <me@ch1p.com>
Diffstat (limited to 'util/ectool')
-rw-r--r--util/ectool/ectool.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/util/ectool/ectool.c b/util/ectool/ectool.c
index be5a899765..bc3d46cd52 100644
--- a/util/ectool/ectool.c
+++ b/util/ectool/ectool.c
@@ -90,6 +90,11 @@ int main(int argc, char *argv[])
{0, 0, 0, 0}
};
+ if (argv[1] == NULL) {
+ print_usage(argv[0]);
+ exit(1);
+ }
+
while ((opt = getopt_long(argc, argv, "vh?Vidqpw:z:",
long_options, &option_index)) != EOF) {
switch (opt) {
@@ -128,6 +133,12 @@ int main(int argc, char *argv[])
}
}
+ if (optind < argc) {
+ fprintf(stderr, "Error: Extra parameter found.\n");
+ print_usage(argv[0]);
+ exit(1);
+ }
+
if (get_ports && get_ec_ports() != 0)
fprintf(stderr, "Cannot get EC ports from /proc/ioports, "
"fallback to default.");