asan: buffer overflow in sh_reloc
authorAlan Modra <amodra@gmail.com>
Wed, 14 Dec 2022 04:16:07 +0000 (14:46 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 14 Dec 2022 11:15:04 +0000 (21:45 +1030)
* coff-sh.c (sh_reloc): Use bfd_reloc_offset_in_range.

bfd/coff-sh.c

index c5b69a8592fda01773721cf290e20571f1580f25..d030c47553973638b8a9325014011bc1eb76018c 100644 (file)
@@ -597,7 +597,8 @@ sh_reloc (bfd *      abfd,
       && bfd_is_und_section (symbol_in->section))
     return bfd_reloc_undefined;
 
-  if (addr > input_section->size)
+  if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd, input_section,
+                                 addr))
     return bfd_reloc_outofrange;
 
   sym_value = get_symbol_value (symbol_in);