File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -371,6 +371,10 @@ class ElfDiscEntry : public DiscEntry {
371371 uint32_t phdr = phdr_offset + (phdr_size * i);
372372 if (int_at (elf_data, phdr + ELF32_PHDR_TYPE) == PT_LOAD) {
373373 uint32_t filesz = int_at (elf_data, phdr + ELF32_PHDR_FILESZ);
374+ if (!filesz) {
375+ // Skip PHDR sections which do not contain any data.
376+ continue ;
377+ }
374378 uint32_t memsz = int_at (elf_data, phdr + ELF32_PHDR_MEMSZ);
375379 uint32_t low = int_at (elf_data, phdr + ELF32_PHDR_PADDR);
376380 uint32_t high = low + memsz - 1 ;
@@ -436,6 +440,9 @@ class ElfDiscEntry : public DiscEntry {
436440 if (int_at (elf_data, phdr + ELF32_PHDR_TYPE) == PT_LOAD) {
437441 uint32_t offset = int_at (elf_data, phdr + ELF32_PHDR_OFFSET);
438442 uint32_t filesz = int_at (elf_data, phdr + ELF32_PHDR_FILESZ);
443+ if (!filesz) {
444+ continue ;
445+ }
439446 uint32_t addr = int_at (elf_data, phdr + ELF32_PHDR_PADDR);
440447 uint32_t file_offset = addr_to_file_offset (addr);
441448 memcpy (&data[file_offset], &elf_data[offset], filesz);
You can’t perform that action at this time.
0 commit comments