diff --git a/tools/elf2uf2/main.cpp b/tools/elf2uf2/main.cpp index b66f082..2c0ddcd 100644 --- a/tools/elf2uf2/main.cpp +++ b/tools/elf2uf2/main.cpp @@ -143,6 +143,9 @@ int read_and_check_elf32_ph_entries(FILE *in, const elf32_header &eh, const addr } if (eh.ph_num) { std::vector entries(eh.ph_num); + if (fseek(in, eh.ph_offset, SEEK_SET)) { + return fail_read_error(); + } if (eh.ph_num != fread(&entries[0], sizeof(struct elf32_ph_entry), eh.ph_num, in)) { return fail_read_error(); }