elf: Simplify phdr checking code (#6302)
This commit is contained in:
parent
c1e26fee02
commit
af6dade945
2 changed files with 6 additions and 12 deletions
|
|
@ -35,18 +35,12 @@ static bool verify_phdr_entry(ELFOBJ *bin, RzBinObjectLoadOptions *options, Elf_
|
|||
|
||||
bool ret = true;
|
||||
|
||||
if (entry->p_filesz > bin->size) {
|
||||
RZ_LOG_WARN("phdr entry: p_filesz (%" PFMTnd " bytes) > binary size (%" PFMT64d " bytes).\n",
|
||||
entry->p_filesz, bin->size);
|
||||
Elf_(Off) end_off;
|
||||
if (!Elf_(rz_bin_elf_add_off)(&end_off, entry->p_offset, entry->p_filesz) || end_off > bin->size) {
|
||||
RZ_LOG_WARN("phdr entry: p_offset (0x%" PFMTnx ") + p_filesz (%" PFMTnd " bytes) "
|
||||
"> binary size (%" PFMT64d " bytes).\n",
|
||||
entry->p_offset, entry->p_filesz, bin->size);
|
||||
ret = false;
|
||||
} else {
|
||||
Elf_(Off) end_off;
|
||||
if (!Elf_(rz_bin_elf_add_off)(&end_off, entry->p_offset, entry->p_filesz) || end_off > bin->size) {
|
||||
RZ_LOG_WARN("phdr entry: p_offset (0x%" PFMTnx ") is invalid for "
|
||||
"p_filesz (%" PFMTnd " bytes) and binary size (%" PFMT64d " bytes).\n",
|
||||
entry->p_offset, entry->p_filesz, bin->size);
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Elf_(rz_bin_elf_add_addr)(NULL, entry->p_vaddr, entry->p_memsz)) {
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ WARNING: Failed to read ELF header (e_shnum).
|
|||
WARNING: Failed to read ELF header (e_shstrndx).
|
||||
WARNING: The binary seems to be a tiny elf (45 bytes). Reload e_phnum value.
|
||||
WARNING: Number of sections is 0.
|
||||
WARNING: phdr entry: p_filesz (65568 bytes) > binary size (45 bytes).
|
||||
WARNING: phdr entry: p_offset (0x0) + p_filesz (65568 bytes) > binary size (45 bytes).
|
||||
WARNING: phdr entry: p_offset (0x0) and p_vaddr (0x10000) are not congruent for p_align (0xc0312ab3).
|
||||
WARNING: The segment 0 at 0x4 seems to be invalid.
|
||||
WARNING: ELF header e_shstrndx value (0) >= number of sections (0).
|
||||
|
|
|
|||
Loading…
Reference in a new issue