From 8cd17eae2fca33671df544fe209a994105531e94 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Wed, 1 Aug 2018 17:21:32 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/27777 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- util/cbmem/cbmem.c | 5 +++++ 1 file changed, 5 insertions(+) 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",