]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: Skip section if name is NULL in print_debug.
authorMark Wielaard <mjw@redhat.com>
Tue, 27 May 2014 08:25:27 +0000 (10:25 +0200)
committerMark Wielaard <mjw@redhat.com>
Tue, 27 May 2014 20:00:46 +0000 (22:00 +0200)
Don't crash and burn when a section doesn't have a name (possibly invalid
ELF file string table). Just try the next section instead of calling strcmp
on NULL.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/readelf.c

index 5535cff72df6c10de0a828b0c569fe504737b5ee..7e680361ab907d3047e2c0f82241c53c878f2d95 100644 (file)
@@ -1,3 +1,7 @@
+2014-05-27  Mark Wielaard  <mjw@redhat.com>
+
+       * readelf.c (print_debug): Skip section if name is NULL.
+
 2014-05-26  Mark Wielaard  <mjw@redhat.com>
 
        * readelf.c (handle_relocs_rela): Print header like handle_relocs_rel
index ea14a09b9c4ba7a3a026da05a879c89b777b8048..6bbe436d3021ebe03781f21dbfed137701fe321e 100644 (file)
@@ -7962,8 +7962,10 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr)
                                       / sizeof (debug_sections[0]));
          const char *name = elf_strptr (ebl->elf, shstrndx,
                                         shdr->sh_name);
-         int n;
+         if (name == NULL)
+           continue;
 
+         int n;
          for (n = 0; n < ndebug_sections; ++n)
            if (strcmp (name, debug_sections[n].name) == 0
 #if USE_ZLIB