asan: unknown write in z80_elf_16_be_reloc
Alan Modra
amodra@gmail.com
Thu Apr 23 10:43:07 GMT 2026
Fix a fuzzed object file misbehaviour.
* elf32-z80.c (z80_elf_16_be_reloc): Sanity check reloc offset.
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))
--
Alan Modra
More information about the Binutils
mailing list