LibELF: validate_program_headers: Validate PT_INTERP header p_filesz > 1
This commit is contained in:
parent
1fa9d9dd68
commit
66b0012bfd
Notes:
sideshowbarker
2024-07-18 23:10:37 +09:00
Author: https://github.com/bcoles Commit: https://github.com/SerenityOS/serenity/commit/66b0012bfd2 Pull-request: https://github.com/SerenityOS/serenity/pull/4978
1 changed files with 5 additions and 0 deletions
|
@ -222,6 +222,11 @@ bool validate_program_headers(const Elf32_Ehdr& elf_header, size_t file_size, co
|
|||
dbgln("Found PT_INTERP header ({}), but the .interp section was not within the buffer :(", header_index);
|
||||
return false;
|
||||
}
|
||||
if (program_header.p_filesz <= 1) {
|
||||
if (verbose)
|
||||
dbgln("Found PT_INTERP header ({}), but p_filesz is invalid ({})", header_index, program_header.p_filesz);
|
||||
return false;
|
||||
}
|
||||
if (interpreter_path)
|
||||
*interpreter_path = String((const char*)&buffer[program_header.p_offset], program_header.p_filesz - 1);
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue