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 linker when passed a corrupt binary input file.


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

commit d7f399a8de4c55eb841db6493597a587fac002de
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Dec 2 17:46:26 2016 +0000

    Fix seg-fault in linker when passed a corrupt binary input file.
    
    	PR lf/20908
    	* elflink.c (bfd_elf_final_link): Check for ELF flavour binaries
    	when following indirect links.

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

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c8085e7..1fe3cd4 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,9 @@
 2016-12-02  Nick Clifton  <nickc@redhat.com>
 
+	PR lf/20908
+	* elflink.c (bfd_elf_final_link): Check for ELF flavour binaries
+	when following indirect links.
+
 	PR ld/20909
 	* aoutx.h (aout_link_add_symbols): Fix off-by-one error in check
 	for an illegal string offset.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 5f87f87..320f3be 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11342,6 +11342,12 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
 	      asection *sec;
 
 	      sec = p->u.indirect.section;
+	      /* See PR 20908 for a reproducer.  */
+	      if (bfd_get_flavour (sec->owner) != bfd_target_elf_flavour)
+		{
+		  _bfd_error_handler (_("%B: not in ELF format"), sec->owner);
+		  goto error_return;
+		}
 	      esdi = elf_section_data (sec);
 
 	      /* Mark all sections which are to be included in the


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