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 <hdegoede@redhat.com>
This commit is contained in:
parent
2d258a30d8
commit
55eec70cea
@ -21,26 +21,21 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define SCRIPT_START 0x43000000
|
#define SCRIPT_START 0x43000000
|
||||||
#define SCRIPT_SIZE 0x20000
|
#define SCRIPT_SIZE 0x20000
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(void) {
|
||||||
char *addr;
|
char *addr;
|
||||||
int fd;
|
int fd;
|
||||||
int i;
|
int i;
|
||||||
int size;
|
|
||||||
|
|
||||||
fd = open("/dev/mem", O_RDONLY);
|
fd = open("/dev/mem", O_RDONLY);
|
||||||
|
addr = (char *)mmap(NULL, SCRIPT_SIZE, PROT_READ, MAP_SHARED, fd, SCRIPT_START);
|
||||||
size = SCRIPT_SIZE;
|
|
||||||
if (argc)
|
|
||||||
size = atoi(argv[1]);
|
|
||||||
|
|
||||||
addr = (char *)mmap(NULL, size, PROT_READ, MAP_SHARED, fd, SCRIPT_START);
|
|
||||||
for (i = 0; i < SCRIPT_SIZE; i++)
|
for (i = 0; i < SCRIPT_SIZE; i++)
|
||||||
putchar(addr[i]);
|
putchar(addr[i]);
|
||||||
munmap(NULL, SCRIPT_SIZE);
|
munmap(addr, SCRIPT_SIZE);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user