readelf: Fix deref-of-null in dump_archive_index()
Commit Message
Pointer, returned from function 'elf_getarhdr' ar readelf.c:13551,
may be NULL and is dereferenced at readelf.c:13553.
Found by RASU JCS.
Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
src/readelf.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -13549,6 +13549,12 @@ dump_archive_index (Elf *elf, const char *fname)
as_off, fname, elf_errmsg (-1));
const Elf_Arhdr *h = elf_getarhdr (subelf);
+ if (h == NULL)
+ {
+ printf ("cannot get archive header in '%s': %s\n",
+ fname, elf_errmsg (-1));
+ return;
+ }
printf (_("Archive member '%s' contains:\n"), h->ar_name);