If there is something wrong with getting the section data it is likely
we won't be able to get the actual section name because the file is
somehow corrupted. Try to get the name, but handle failure gracefully.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
+2015-06-18 Mark Wielaard <mjw@redhat.com>
+
+ * strings.c (readelf): Use "<unknown>" if we cannot retrieve section
+ name.
+
2015-06-09 Mark Wielaard <mjw@redhat.com>
* addr2line.c (print_dwarf_function): Always free scopes before
|| fdlen - shdr->sh_offset < shdr->sh_size)
{
size_t strndx = 0;
- elf_getshdrstrndx (elf, &strndx);
+ const char *sname;
+ if (unlikely (elf_getshdrstrndx (elf, &strndx) < 0))
+ sname = "<unknown>";
+ else
+ sname = elf_strptr (elf, strndx, shdr->sh_name) ?: "<unknown>";
error (0, 0,
gettext ("Skipping section %zd '%s' data outside file"),
- elf_ndxscn (scn), elf_strptr (elf, strndx, shdr->sh_name));
+ elf_ndxscn (scn), sname);
result = 1;
}
else