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] Fix seg-fault in the BFD parsing a corrupt input binary.


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

commit 20bd1b6ba53491e4979c03a4f679d0d17b9b9046
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Jun 21 13:18:46 2017 +0100

    Fix seg-fault in the BFD parsing a corrupt input binary.
    
    	PR binutils/21645
    	* reloc.c (bfd_generic_get_relocated_section_contents): Fail if
    	bfd_get_full_section_contents returns no contents.

Diff:
---
 bfd/ChangeLog | 6 ++++++
 bfd/coff-sh.c | 1 +
 bfd/reloc.c   | 3 +++
 3 files changed, 10 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c92ed67..1d9ba02 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
 2017-06-21  Nick Clifton  <nickc@redhat.com>
 
+	PR binutils/21645
+	* reloc.c (bfd_generic_get_relocated_section_contents): Fail if
+	bfd_get_full_section_contents returns no contents.
+
+2017-06-21  Nick Clifton  <nickc@redhat.com>
+
 	PR binutils/21638
 	* vms-alpha.c (_bfd_vms_slurp_egsd): Check for an undersized
 	record.
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c
index dd8090c..d76f98a 100644
--- a/bfd/coff-sh.c
+++ b/bfd/coff-sh.c
@@ -2910,6 +2910,7 @@ sh_coff_get_relocated_section_contents (bfd *output_bfd,
   struct internal_reloc *internal_relocs = NULL;
   struct internal_syment *internal_syms = NULL;
 
+fprintf (stderr, "DATA = %p\n", data);
   /* We only need to handle the case of relaxing, or of having a
      particular set of section contents, specially.  */
   if (relocatable
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 8dedfe8..ee01d88 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -8126,6 +8126,9 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
   if (!bfd_get_full_section_contents (input_bfd, input_section, &data))
     return NULL;
 
+  if (data == NULL)
+    return NULL;
+
   if (reloc_size == 0)
     return data;


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