This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Prevent an illegal memory access in readelf when attempting to parse a corrupt ELF file.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f425ec6600b69e39eb605f3128806ff688137ea8

commit f425ec6600b69e39eb605f3128806ff688137ea8
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Nov 30 10:25:01 2017 +0000

    Prevent an illegal memory access in readelf when attempting to parse a corrupt ELF file.
    
    	PR 22510
    	* readelf.c (load_debug_section): Fail if there are no section
    	headers available.

Diff:
---
 binutils/ChangeLog | 6 ++++++
 binutils/readelf.c | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index bacb762..1ea16e4 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -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
diff --git a/binutils/readelf.c b/binutils/readelf.c
index a1f43e6..e0230c7 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]