commit | 2cf86cfecb3c6db21be0da826630fbfe6950af15 | [log] [tgz] |
---|---|---|
author | graham sanderson <graham.sanderson@raspberrypi.com> | Wed Jul 14 16:01:47 2021 -0500 |
committer | graham sanderson <graham.sanderson@raspberrypi.com> | Wed Jul 14 16:01:47 2021 -0500 |
tree | f65738ef2ca00b7d999e80aef7ccd32a6a9182fc | |
parent | 3b1bcd391b6274b2b08a7a21619e42fd40194ab4 [diff] |
fix parsing of ELF where the program header does not directly follow the file header
diff --git a/main.cpp b/main.cpp index 89059c5..aa7790d 100644 --- a/main.cpp +++ b/main.cpp
@@ -1210,6 +1210,9 @@ } if (eh.ph_num) { vector<elf32_ph_entry> entries(eh.ph_num); + if (fseek(file, eh.ph_offset, SEEK_SET)) { + return fail_read_error(); + } if (eh.ph_num != fread(&entries[0], sizeof(struct elf32_ph_entry), eh.ph_num, file)) { fail_read_error(); }