01917d
commit ec93045b400ec68b0c5716d75f27a87533b57058
01917d
Author: Nick Clifton <nickc@redhat.com>
01917d
Date:   Tue Jan 6 17:54:02 2015 +0000
01917d
01917d
    Fix memory access violations for objdump triggered by fuzzed binaries.
01917d
    
01917d
            PR binutils/17512
01917d
            * reloc.c (bfd_get_reloc_size): Handle a reloc size of -1.
01917d
            (bfd_perform_relocation): Include the size of the reloc in the
01917d
            test for an out of range relocation.
01917d
            (bfd_generic_get_relocated_section_contents): Remove reloc range
01917d
            test.
01917d
01917d
### a/bfd/ChangeLog
01917d
### b/bfd/ChangeLog
01917d
## -1,6 +1,12 @@
01917d
 2015-01-06  Nick Clifton  <nickc@redhat.com>
01917d
 
01917d
 	PR binutils/17512
01917d
+	* reloc.c (bfd_get_reloc_size): Handle a reloc size of -1.
01917d
+	(bfd_perform_relocation): Include the size of the reloc in the
01917d
+	test for an out of range relocation.
01917d
+	(bfd_generic_get_relocated_section_contents): Remove reloc range
01917d
+	test.
01917d
+
01917d
 	* coff-i860.c (CALC_ADDEND): Always set an addend value.
01917d
 	* tekhex.c (getvalue): Add an end pointer parameter.  Use it to
01917d
 	avoid reading off the end of the buffer.
01917d
--- a/bfd/reloc.c
01917d
+++ b/bfd/reloc.c
01917d
@@ -437,6 +437,7 @@ bfd_get_reloc_size (reloc_howto_type *howto)
01917d
     case 3: return 0;
01917d
     case 4: return 8;
01917d
     case 8: return 16;
01917d
+    case -1: return 2;
01917d
     case -2: return 4;
01917d
     default: abort ();
01917d
     }
01917d
@@ -618,7 +619,11 @@ bfd_perform_relocation (bfd *abfd,
01917d
     }
01917d
 
01917d
   /* Is the address of the relocation really within the section?  */
01917d
-  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
01917d
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)
01917d
+      /* PR 17512: file: c146ab8b.
01917d
+	 PR 17512: file: 46dff27f.
01917d
+	 Include the size of the reloc in the test for out of range addresses.  */
01917d
+      - bfd_get_reloc_size (howto))
01917d
     return bfd_reloc_outofrange;
01917d
 
01917d
   /* Work out which section the relocation is targeted at and the
01917d
@@ -7623,10 +7628,6 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
01917d
 	      (*parent)->howto = &none_howto;
01917d
 	      r = bfd_reloc_ok;
01917d
 	    }
01917d
-	  /* PR 17512: file: c146ab8b.  */
01917d
-	  else if ((*parent)->address * bfd_octets_per_byte (abfd)
01917d
-		   >= bfd_get_section_size (input_section))
01917d
-	    r = bfd_reloc_outofrange;
01917d
 	  else
01917d
 	    r = bfd_perform_relocation (input_bfd,
01917d
 					*parent,