mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-07 17:15:26 +00:00
LibELF: Don't validate PT_LOAD alignment in ET_CORE files
This was causing CrashDaemon to choke on our coredumps. Note that we didn't care about the validation failures before this change either, this patch simply reorders the checks to avoid divide-by-zero when validating an ET_CORE file.
This commit is contained in:
@@ -236,16 +236,16 @@ bool validate_program_headers(const ElfW(Ehdr) & elf_header, size_t file_size, c
|
||||
return false;
|
||||
}
|
||||
|
||||
if (program_header.p_type == PT_LOAD && program_header.p_align % (size_t)PAGE_SIZE != 0) {
|
||||
if (elf_header.e_type != ET_CORE) {
|
||||
if (elf_header.e_type != ET_CORE) {
|
||||
if (program_header.p_type == PT_LOAD && program_header.p_align % (size_t)PAGE_SIZE != 0) {
|
||||
if (verbose)
|
||||
dbgln("Program header ({}) with p_type PT_LOAD has p_align ({}) not divisible by page size ({})", header_index, program_header.p_align, PAGE_SIZE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (program_header.p_type == PT_LOAD && program_header.p_vaddr % program_header.p_align != program_header.p_offset % program_header.p_align) {
|
||||
if (elf_header.e_type != ET_CORE) {
|
||||
if (elf_header.e_type != ET_CORE) {
|
||||
if (program_header.p_type == PT_LOAD && program_header.p_vaddr % program_header.p_align != program_header.p_offset % program_header.p_align) {
|
||||
if (verbose)
|
||||
dbgln("Program header ({}) with p_type PT_LOAD has mis-aligned p_vaddr ({:x})", header_index, program_header.p_vaddr);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user