]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Fix abort() on missing section headers.
authorJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 3 Mar 2014 23:04:27 +0000 (00:04 +0100)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 3 Mar 2014 23:04:27 +0000 (00:04 +0100)
libdw/
2014-03-03  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix abort() on missing section headers.
* dwarf_begin_elf.c (check_section): Replace abort call by goto err.
New label err to return NULL.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
libdw/ChangeLog
libdw/dwarf_begin_elf.c

index 19a2a505cdef9cee1c6ee011e548bae32d9d0e09..1d9b9a3b1c62d7cff835752ea9171493ac2c4cf0 100644 (file)
@@ -1,3 +1,9 @@
+2014-03-03  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       Fix abort() on missing section headers.
+       * dwarf_begin_elf.c (check_section): Replace abort call by goto err.
+       New label err to return NULL.
+
 2014-02-05  Josh Stone  <jistone@redhat.com>
 
        * dwarf_decl_file.c (dwarf_decl_file): Read the idx as unsigned.
index 6cf3aa17855df880e879c6881285bbcf43f15114..79daeacb682d5917df92eaf6738898817a82adc0 100644 (file)
@@ -187,9 +187,9 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp)
   /* Get the section header data.  */
   shdr = gelf_getshdr (scn, &shdr_mem);
   if (shdr == NULL)
-    /* This should never happen.  If it does something is
-       wrong in the libelf library.  */
-    abort ();
+    /* We may read /proc/PID/mem with only program headers mapped and section
+       headers out of the mapped pages.  */
+    goto err;
 
   /* Ignore any SHT_NOBITS sections.  Debugging sections should not
      have been stripped, but in case of a corrupt file we won't try
@@ -215,6 +215,7 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp)
     {
       /* The section name must be valid.  Otherwise is the ELF file
         invalid.  */
+    err:
       __libdw_free_zdata (result);
       Dwarf_Sig8_Hash_free (&result->sig8_hash);
       __libdw_seterrno (DWARF_E_INVALID_ELF);