Error out if no object file header

Quit the program if object file header can't be read or is smaller than
expected.
This commit is contained in:
Thomas Preud'homme 2011-10-05 21:51:22 +02:00
parent a8f2e34c5f
commit 8a440f169b
1 changed files with 6 additions and 1 deletions

View File

@ -488,7 +488,12 @@ static Symbols loadSyms(const char *fname)
perror("opening object file");
quit("Could not open object file.");
}
read(fd, &hdr, sizeof(hdr));
if (read(fd, &hdr, sizeof(hdr)) < (int) sizeof(hdr))
{
fprintf(stderr, "'%s': ", fname);
perror("reading object file ELF header");
quit("Could not read object file ELF header.");
}
verify_ident(&hdr);
if (!find_stables(&hdr, fd, syms)) {
deleteSyms(syms);