summaryrefslogtreecommitdiffstats
path: root/libdw
diff options
context:
space:
mode:
authorJan Kratochvil <[email protected]>2014-03-04 00:04:27 +0100
committerJan Kratochvil <[email protected]>2014-03-04 00:04:27 +0100
commitdff2a99d84a756792f65d31fa19becce792f2ca5 (patch)
treedada7f00e64a3325912e978e5bf9a164485fc856 /libdw
parent8f4402f7cd1a8b82f890a219d97106cbf918cf92 (diff)
Fix abort() on missing section headers.
libdw/ 2014-03-03 Jan Kratochvil <[email protected]> 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 <[email protected]>
Diffstat (limited to 'libdw')
-rw-r--r--libdw/ChangeLog6
-rw-r--r--libdw/dwarf_begin_elf.c7
2 files changed, 10 insertions, 3 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 19a2a505..1d9b9a3b 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-03 Jan Kratochvil <[email protected]>
+
+ 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 <[email protected]>
* dwarf_decl_file.c (dwarf_decl_file): Read the idx as unsigned.
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 6cf3aa17..79daeacb 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -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);