Catch bad file in readelf
This commit is contained in:
parent
36ca4d420b
commit
0ac9adf3f0
|
@ -13,6 +13,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <kernel/elf.h>
|
#include <kernel/elf.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +47,11 @@ int main(int argc, char ** argv) {
|
||||||
/* Open the requested binary */
|
/* Open the requested binary */
|
||||||
binary = fopen(argv[1], "r");
|
binary = fopen(argv[1], "r");
|
||||||
|
|
||||||
|
if (!binary) {
|
||||||
|
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[1], strerror(errno));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Jump to the end so we can get the size */
|
/* Jump to the end so we can get the size */
|
||||||
fseek(binary, 0, SEEK_END);
|
fseek(binary, 0, SEEK_END);
|
||||||
binary_size = ftell(binary);
|
binary_size = ftell(binary);
|
||||||
|
|
Loading…
Reference in New Issue