diff options
author | Mark Wielaard <mark@klomp.org> | 2019-04-28 18:02:05 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2019-04-28 18:02:05 +0200 |
commit | 0720b2ca333186b0d3f4a5b73d5ae2bd8fc8cb4b (patch) | |
tree | b65476b46d729a9d4750144556439c289ad75cf4 /src | |
parent | 207d8ec3778a3101ee1b8ece9c63c0ff97450789 (diff) |
size: Robustify against gelf_getshdr returning NULL.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 7 | ||||
-rw-r--r-- | src/size.c | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 3020bd76..e3e411ef 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,12 @@ 2019-04-28 Mark Wielaard <mark@klomp.org> + * size.c (show_sysv): Call INTERNAL_ERROR if gelf_getshdr + returns NULL. + (show_sysv_one_line): Call error with EXIT_FAILURE if + gelf_getshdr returns NULL. + +2019-04-28 Mark Wielaard <mark@klomp.org> + * nm.c (show_symbols_sysv): Check gelf_getshdr doesn't return NULL. Simplify naming of invalid sections, don't use alloca. @@ -428,6 +428,9 @@ show_sysv (Elf *elf, const char *prefix, const char *fname, GElf_Shdr shdr_mem; GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); + if (shdr == NULL) + INTERNAL_ERROR (fullname); + /* Ignore all sections which are not used at runtime. */ if ((shdr->sh_flags & SHF_ALLOC) != 0) { @@ -475,6 +478,9 @@ show_sysv_one_line (Elf *elf) GElf_Shdr shdr_mem; GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); + if (unlikely (shdr == NULL)) + error (EXIT_FAILURE, 0, gettext ("cannot get section header")); + /* Ignore all sections which are not used at runtime. */ if ((shdr->sh_flags & SHF_ALLOC) == 0) continue; |