aboutsummaryrefslogtreecommitdiff
path: root/disassembler_elf.cc
diff options
context:
space:
mode:
Diffstat (limited to 'disassembler_elf.cc')
-rw-r--r--disassembler_elf.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/disassembler_elf.cc b/disassembler_elf.cc
index ff3b085..2405374 100644
--- a/disassembler_elf.cc
+++ b/disassembler_elf.cc
@@ -208,8 +208,14 @@ bool DisassemblerElf<Traits>::ParseHeader() {
// Skip empty sections. These don't affect |offset_bound|, and don't
// contribute to RVA-offset mapping.
- if (section->sh_size == 0)
+ if (section->sh_size == 0) {
+ // Skipping empty sections is only safe if the |sh_offset| is within the
+ // image. Fail if this is not true as the input is ill-formed.
+ if (section->sh_offset >= image_.size())
+ return false;
+
continue;
+ }
// Extract dimensions to 32-bit integers to facilitate conversion. Range of
// values was ensured above when checking that the section is bounded.