asan: unknown write in z80_elf_16_be_reloc

Message ID aen3u_6aPVWoRrRP@squeak.grove.modra.org
State New
Headers
Series asan: unknown write in z80_elf_16_be_reloc |

Commit Message

Alan Modra April 23, 2026, 10:43 a.m. UTC
  Fix a fuzzed object file misbehaviour.

	* elf32-z80.c (z80_elf_16_be_reloc): Sanity check reloc offset.
  

Patch

diff --git a/bfd/elf32-z80.c b/bfd/elf32-z80.c
index 8eacfd7e464..1dc2e192adc 100644
--- a/bfd/elf32-z80.c
+++ b/bfd/elf32-z80.c
@@ -580,6 +580,10 @@  z80_elf_16_be_reloc (bfd *abfd,
     return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
 				  input_section, output_bfd, error_message);
 
+  if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
+				  input_section, octets))
+    return bfd_reloc_outofrange;
+
   /* Get symbol value.  */
   val = 0;
   if (!bfd_is_com_section (symbol->section))