]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
size: Robustify against gelf_getshdr returning NULL.
authorMark Wielaard <mark@klomp.org>
Sun, 28 Apr 2019 16:02:05 +0000 (18:02 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 28 Apr 2019 16:02:05 +0000 (18:02 +0200)
Signed-off-by: Mark Wielaard <mark@klomp.org>
src/ChangeLog
src/size.c

index 3020bd76894c087ee71f1e526c9460a733eb6629..e3e411ef50807fc1bf7316317b461243fc40ea25 100644 (file)
@@ -1,3 +1,10 @@
+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
index f01fd880ccfd7fa92835e77e412a2ab84ea7b936..a25d4471f1c36459f1cecfeccd655892be60b711 100644 (file)
@@ -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;