diff options
author | Mark Wielaard <[email protected]> | 2013-07-02 11:22:35 +0200 |
---|---|---|
committer | Mark Wielaard <[email protected]> | 2013-07-08 12:24:08 +0200 |
commit | 5704c8c4fa717b6e9c2d2e4304dfbc810ad42e4b (patch) | |
tree | 5a3138ec873ae3713fa969accc9799a10bd789f6 /libdw/dwarf_getcfi_elf.c | |
parent | 79277076db51fd0d025168c85074bf0370d70738 (diff) |
getcfi_scn_eh_frame: Don't crash and burn when .eh_frame bits aren't there.
Trying to read non-existing bits sometimes works and normally a sanity
check will fail. But it could also lead to an unexpected crash much later
when trying to use the non-existing data.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libdw/dwarf_getcfi_elf.c')
-rw-r--r-- | libdw/dwarf_getcfi_elf.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libdw/dwarf_getcfi_elf.c b/libdw/dwarf_getcfi_elf.c index ba00e05e..a423ef3d 100644 --- a/libdw/dwarf_getcfi_elf.c +++ b/libdw/dwarf_getcfi_elf.c @@ -280,8 +280,13 @@ getcfi_shdr (Elf *elf, const GElf_Ehdr *ehdr) hdr_vaddr = shdr->sh_addr; } else if (!strcmp (name, ".eh_frame")) - return getcfi_scn_eh_frame (elf, ehdr, scn, shdr, - hdr_scn, hdr_vaddr); + { + if (shdr->sh_type == SHT_PROGBITS) + return getcfi_scn_eh_frame (elf, ehdr, scn, shdr, + hdr_scn, hdr_vaddr); + else + return NULL; + } } } |