Prevent an illegal memory access in readelf when attempting to parse a corrupt ELF...
authorNick Clifton <nickc@redhat.com>
Thu, 30 Nov 2017 10:25:01 +0000 (10:25 +0000)
committerNick Clifton <nickc@redhat.com>
Thu, 30 Nov 2017 10:25:01 +0000 (10:25 +0000)
PR 22510
* readelf.c (load_debug_section): Fail if there are no section
headers available.

binutils/ChangeLog
binutils/readelf.c

index bacb7628b86bccf6e8e07508c0b655f90986ecc9..1ea16e4118e631824c9cd538b0d010bd9cedd932 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-30  Nick Clifton  <nickc@redhat.com>
+
+       PR 22510
+       * readelf.c (load_debug_section): Fail if there are no section
+       headers available.
+
 2017-11-29  Nick Clifton  <nickc@redhat.com>
 
        PR 22508
index a1f43e612a3b74e19f51946652c8016af920ca13..e0230c7cc780b49a8b18b8a994325cf545aa3dfc 100644 (file)
@@ -13574,6 +13574,10 @@ load_debug_section (enum dwarf_section_display_enum debug, void * data)
   Elf_Internal_Shdr * sec;
   Filedata * filedata = (Filedata *) data;
 
+  /* Without section headers we cannot find any sections.  */
+  if (filedata->section_headers == NULL)
+    return FALSE;
+
   if (filedata->string_table == NULL)
     {
       Elf_Internal_Shdr * strs;