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 running strip on a corrupt binary.


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

commit 8b929e420a810afe23d5ba57a98109c74d1d5816
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Dec 6 16:26:42 2016 +0000

    Fix seg-fault running strip on a corrupt binary.
    
    	PR binutils/20930
    	* objcopy.c (mark_symbols_used_in_relocations): Check for a null
    	symbol pointer pointer before attempting to mark the symbol as
    	kept.

Diff:
---
 binutils/ChangeLog | 7 +++++++
 binutils/objcopy.c | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index fdbb056..b3429f7 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2016-12-06  Nick Clifton  <nickc@redhat.com>
+
+	PR binutils/20930
+	* objcopy.c (mark_symbols_used_in_relocations): Check for a null
+	symbol pointer pointer before attempting to mark the symbol as
+	kept.
+
 2016-12-05  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
 	* MAINTAINERS: Add myself as maintainer for the SPARC targets.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 6a398ce..c780012 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3551,8 +3551,9 @@ mark_symbols_used_in_relocations (bfd *ibfd, sec_ptr isection, void *symbolsarg)
      special bfd section symbols, then mark it with BSF_KEEP.  */
   for (i = 0; i < relcount; i++)
     {
-      /* See PR 20923 for a reproducer for the NULL test.  */
+      /* See PRs 20923 and 20930 for reproducers for the NULL tests.  */
       if (relpp[i]->sym_ptr_ptr != NULL
+	  && * relpp[i]->sym_ptr_ptr != NULL
 	  && *relpp[i]->sym_ptr_ptr != bfd_com_section_ptr->symbol
 	  && *relpp[i]->sym_ptr_ptr != bfd_abs_section_ptr->symbol
 	  && *relpp[i]->sym_ptr_ptr != bfd_und_section_ptr->symbol)


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