]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/coff-m88k.c
Fix a memory access violation when attempting to parse a corrupt COFF binary with...
[thirdparty/binutils-gdb.git] / bfd / coff-m88k.c
index ebe4fd3e4f61df83f4d421b36408ee07993763eb..6314bd35f9f22b4d273eec615e3e2f215e178258 100644 (file)
@@ -72,10 +72,17 @@ m88k_special_reloc (bfd *abfd,
        {
          bfd_vma output_base = 0;
          bfd_vma addr = reloc_entry->address;
-         bfd_vma x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
+         bfd_vma x;
          asection *reloc_target_output_section;
          long relocation = 0;
 
+         if (! bfd_reloc_offset_in_range (howto, abfd, input_section,
+                                          reloc_entry->address
+                                          * bfd_octets_per_byte (abfd)))
+           return bfd_reloc_outofrange;
+
+         x = bfd_get_16 (abfd, (bfd_byte *) data + addr);        
+
          /* Work out which section the relocation is targeted at and the
             initial relocation command value.  */