PR23141, SIGSEGV in bfd_elf_set_group_contents

Message ID 20180508130214.GA28782@bubble.grove.modra.org
State New
Headers show
Series
  • PR23141, SIGSEGV in bfd_elf_set_group_contents
Related show

Commit Message

Alan Modra May 8, 2018, 1:02 p.m.
Another fuzzing fix.  I think it's reasonable to simply strip out any
group section that is too weird for objcopy to handle.

	PR 23141
	* objcopy.c (is_strip_section): Strip groups without a valid
	signature symbol.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index fadc957243..3563792304 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1343,14 +1343,15 @@  is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
       const char *gname;
       asection *elt, *first;
 
+      gsym = group_signature (sec);
+      /* Strip groups without a valid signature.  */
+      if (gsym == NULL)
+	return TRUE;
+
       /* PR binutils/3181
 	 If we are going to strip the group signature symbol, then
 	 strip the group section too.  */
-      gsym = group_signature (sec);
-      if (gsym != NULL)
-	gname = gsym->name;
-      else
-	gname = sec->name;
+      gname = gsym->name;
       if ((strip_symbols == STRIP_ALL
 	   && !is_specified_symbol (gname, keep_specific_htab))
 	  || is_specified_symbol (gname, strip_specific_htab))