]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
getcfi_scn_eh_frame: Don't crash and burn when .eh_frame bits aren't there.
authorMark Wielaard <mjw@redhat.com>
Tue, 2 Jul 2013 09:22:35 +0000 (11:22 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 8 Jul 2013 10:24:08 +0000 (12:24 +0200)
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 <mjw@redhat.com>
libdw/ChangeLog
libdw/dwarf_getcfi_elf.c

index 700c166d709dac3ea0e54fa99d39fc3d32151197..22f8b0c32574e6ae51f013d85af568fc1a1ea419 100644 (file)
@@ -1,3 +1,7 @@
+2013-07-02  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_getcfi_elf.c (getcfi_shdr): Check sh_type == SHT_PROGBITS.
+
 2013-06-26  Mark Wielaard  <mjw@redhat.com>
 
        * libdw_visit_scopes.c (__libdw_visit_scopes): Don't reject root
index ba00e05efd98e2b385205b3b75c6dcce2528cd08..a423ef3df9d6869121e16cbd492d5ba214fd69aa 100644 (file)
@@ -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;
+           }
        }
     }