diff options
author | Itamar <itamar8910@gmail.com> | 2020-12-04 12:19:50 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-14 23:05:53 +0100 |
commit | 79769ee74e5cf566dc10adb164b87f0a98e33277 (patch) | |
tree | f3294047cc64b38f074433cb32a4dbb129e0176a /Libraries/LibELF/Validation.cpp | |
parent | 07b49573612628cc6388e9fe30083dc9912b6a7b (diff) | |
download | serenity-79769ee74e5cf566dc10adb164b87f0a98e33277.zip |
LibELF: Allow elf files with no section header to pass validation
Diffstat (limited to 'Libraries/LibELF/Validation.cpp')
-rw-r--r-- | Libraries/LibELF/Validation.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Libraries/LibELF/Validation.cpp b/Libraries/LibELF/Validation.cpp index 8363cb8451..cb042b499c 100644 --- a/Libraries/LibELF/Validation.cpp +++ b/Libraries/LibELF/Validation.cpp @@ -93,7 +93,7 @@ bool validate_elf_header(const Elf32_Ehdr& elf_header, size_t file_size, bool ve return false; } - if (elf_header.e_phoff < elf_header.e_ehsize || elf_header.e_shoff < elf_header.e_ehsize) { + if (elf_header.e_phoff < elf_header.e_ehsize || (elf_header.e_shnum != SHN_UNDEF && elf_header.e_shoff < elf_header.e_ehsize)) { if (verbose) { dbgprintf("SHENANIGANS! program header offset (%d) or section header offset (%d) overlap with ELF header!\n", elf_header.e_phoff, elf_header.e_shoff); @@ -148,7 +148,7 @@ bool validate_elf_header(const Elf32_Ehdr& elf_header, size_t file_size, bool ve return false; } - if (elf_header.e_shoff < end_of_last_program_header) { + if (elf_header.e_shoff != SHN_UNDEF && elf_header.e_shoff < end_of_last_program_header) { if (verbose) { dbgprintf("SHENANIGANS! Section header table begins at file offset %d, which is within program headers [ %d - %zu ]!\n", elf_header.e_shoff, elf_header.e_phoff, end_of_last_program_header); |