asan: buffer overflow in sh_reloc

Message ID Y5m285CXyYl9DPU6@squeak.grove.modra.org
State Repeat Merge
Headers
Series asan: buffer overflow in sh_reloc |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Alan Modra Dec. 14, 2022, 11:43 a.m. UTC
  * coff-sh.c (sh_reloc): Use bfd_reloc_offset_in_range.
  

Patch

diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c
index c5b69a8592f..d030c475539 100644
--- a/bfd/coff-sh.c
+++ b/bfd/coff-sh.c
@@ -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);