From 55eec70ceafc4b8b25b4ddcd613c9ca10e41dcf7 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 8 Dec 2015 13:01:45 +0100 Subject: [PATCH] script_extractor: Remove unnecessary size argument The script_extractor tool before this commit used to take a size argument on the cmdline, but the passed in size was only used in some places not in others. Leading to a segfault if the passed in argument was not exactly the same as SCRIPT_SIZE. This commit drops the argument, so that script_extractor will just work. Signed-off-by: Hans de Goede --- script_extractor.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/script_extractor.c b/script_extractor.c index 52d817f..25d537c 100644 --- a/script_extractor.c +++ b/script_extractor.c @@ -21,26 +21,21 @@ #include #include #include +#include #define SCRIPT_START 0x43000000 #define SCRIPT_SIZE 0x20000 -int main(int argc, char *argv[]) { +int main(void) { char *addr; int fd; int i; - int size; fd = open("/dev/mem", O_RDONLY); - - size = SCRIPT_SIZE; - if (argc) - size = atoi(argv[1]); - - addr = (char *)mmap(NULL, size, PROT_READ, MAP_SHARED, fd, SCRIPT_START); + addr = (char *)mmap(NULL, SCRIPT_SIZE, PROT_READ, MAP_SHARED, fd, SCRIPT_START); for (i = 0; i < SCRIPT_SIZE; i++) putchar(addr[i]); - munmap(NULL, SCRIPT_SIZE); + munmap(addr, SCRIPT_SIZE); close(fd); return 0;