Fix seg-fault running strip on a corrupt binary.
authorNick Clifton <nickc@redhat.com>
Tue, 6 Dec 2016 15:58:15 +0000 (15:58 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 6 Dec 2016 15:58:15 +0000 (15:58 +0000)
PR binutils/20929
* aoutx.h (squirt_out_relocs): Check for relocs without an
associated symbol.

bfd/ChangeLog
bfd/aoutx.h

index 351721b535b741901715e602bf227d2002cdfa4f..fb3f3f41f7cdefd25d6b5fac4741dcbe7261c29b 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-06  Nick Clifton  <nickc@redhat.com>
+
+       PR binutils/20929
+       * aoutx.h (squirt_out_relocs): Check for relocs without an
+       associated symbol.
+
 2016-12-06  Alan Modra  <amodra@gmail.com>
 
        * elf64-ppc.c (ok_lo_toc_insn): Add r_type param.  Recognize
index 43e5f8d218dec8e651b1bbde8ee882c1bc2027a6..c64f28868967118b96d90f10d02b4a8716efb645 100644 (file)
@@ -2395,10 +2395,15 @@ NAME (aout, squirt_out_relocs) (bfd *abfd, asection *section)
           count != 0;
           --count, natptr += each_size, ++generic)
        {
-         if ((*generic)->howto == NULL)
+         /* PR 20921: If the howto field has not been initialised then skip
+            this reloc.
+            PR 20929: Similarly for the symbol field.  */
+         if ((*generic)->howto == NULL
+             || (*generic)->sym_ptr_ptr == NULL)
            {
              bfd_set_error (bfd_error_invalid_operation);
-             _bfd_error_handler (_("%B: attempt to write out unknown reloc type"), abfd);
+             _bfd_error_handler (_("\
+%B: attempt to write out unknown reloc type"), abfd);
              return FALSE;
            }
          MY_swap_ext_reloc_out (abfd, *generic,
@@ -2411,12 +2416,12 @@ NAME (aout, squirt_out_relocs) (bfd *abfd, asection *section)
           count != 0;
           --count, natptr += each_size, ++generic)
        {
-         /* PR 20921: If the howto field has not been initialised then skip
-            this reloc.  */
-         if ((*generic)->howto == NULL)
+         if ((*generic)->howto == NULL
+             || (*generic)->sym_ptr_ptr == NULL)
            {
              bfd_set_error (bfd_error_invalid_operation);
-             _bfd_error_handler (_("%B: attempt to write out unknown reloc type"), abfd);
+             _bfd_error_handler (_("\
+%B: attempt to write out unknown reloc type"), abfd);
              return FALSE;
            }
          MY_swap_std_reloc_out (abfd, *generic,
This page took 0.028109 seconds and 4 git commands to generate.