Fix illegal memory access triggered by an attempt to disassemble a corrupt RISC-V binary.

PR 28303
	* elfxx-riscv.c (riscv_elf_add_sub_reloc): Add check for out of
	range relocs.
This commit is contained in:
Nick Clifton
2021-09-07 09:44:17 +01:00
parent 5d2deb81fa
commit 3f1a2892e1
2 changed files with 13 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2021-09-07 Nick Clifton <nickc@redhat.com>
PR 28303
* elfxx-riscv.c (riscv_elf_add_sub_reloc): Add check for out of
range relocs.
2021-08-10 Nick Clifton <nickc@redhat.com>
* po/sr.po: Updated Serbian translation.

View File

@ -1002,6 +1002,13 @@ riscv_elf_add_sub_reloc (bfd *abfd,
relocation = symbol->value + symbol->section->output_section->vma
+ symbol->section->output_offset + reloc_entry->addend;
bfd_size_type octets = reloc_entry->address
* bfd_octets_per_byte (abfd, input_section);
if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
input_section, octets))
return bfd_reloc_outofrange;
bfd_vma old_value = bfd_get (howto->bitsize, abfd,
data + reloc_entry->address);