mirror of
https://github.com/yuzu-emu/breakpad
synced 2024-11-25 23:07:45 +00:00
linux: Fix segfault when there is no section header in ELF file
Some vendor library doesn't contain the section header. It causes segmentation fault in `FindElfClassSection`. > e_shoff: > This member holds the section header table's file offset in bytes. > If the file has no section header table this member holds zero. Change-Id: Id98d6ff3bd16af4541deb5a55a8fad2fa74eda23 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2354427 Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
087795c851
commit
62d9272419
1 changed files with 6 additions and 0 deletions
|
@ -57,6 +57,12 @@ void FindElfClassSection(const char* elf_base,
|
|||
const Ehdr* elf_header = reinterpret_cast<const Ehdr*>(elf_base);
|
||||
assert(elf_header->e_ident[EI_CLASS] == ElfClass::kClass);
|
||||
|
||||
if (elf_header->e_shoff == 0) {
|
||||
*section_start = NULL;
|
||||
*section_size = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const Shdr* sections =
|
||||
GetOffset<ElfClass, Shdr>(elf_header, elf_header->e_shoff);
|
||||
const Shdr* section_names = sections + elf_header->e_shstrndx;
|
||||
|
|
Loading…
Reference in a new issue