LibELF: validate_program_headers: Validate PT_INTERP header p_filesz > 1

This commit is contained in:
Brendan Coles 2021-01-16 17:35:46 +00:00 committed by Andreas Kling
parent 1fa9d9dd68
commit 66b0012bfd
Notes: sideshowbarker 2024-07-18 23:10:37 +09:00

View File

@ -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;