summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2018-08-01 17:21:32 +0200
committerPatrick Georgi <pgeorgi@google.com>2018-08-02 21:55:20 +0000
commit8cd17eae2fca33671df544fe209a994105531e94 (patch)
treecc3976c021fff5e6c78b1a81eba3be4a49f28c57 /util
parent4af5d9a94a2b0ac7d5a4c9780f005c0d52489e1f (diff)
downloadcoreboot-8cd17eae2fca33671df544fe209a994105531e94.tar.xz
util/cbmem: Handle arguments more carefully
Check if all arguments are handled by getopt and if not print the usage. Change-Id: Iccbb65ca768a62791af54afd9b7903495bc690af Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/27777 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/cbmem/cbmem.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index 3435c4c667..8ab80b0a59 100644
--- a/util/cbmem/cbmem.c
+++ b/util/cbmem/cbmem.c
@@ -1327,6 +1327,11 @@ int main(int argc, char** argv)
}
}
+ if (optind < argc) {
+ fprintf(stderr, "Error: Extra parameter found.\n");
+ print_usage(argv[0], 1);
+ }
+
mem_fd = open("/dev/mem", O_RDONLY, 0);
if (mem_fd < 0) {
fprintf(stderr, "Failed to gain memory access: %s\n",