This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RFA: Detect corrupt relocs in mips BFD
- To: ulfc at calypso dot engr dot sgi dot com
- Subject: RFA: Detect corrupt relocs in mips BFD
- From: Nick Clifton <nickc at cygnus dot com>
- Date: Fri, 21 Jul 2000 10:14:50 -0700
- CC: binutils at sourceware dot cygnus dot com
Hi Ulf,
I recently ran across a case where the MIPS linker was generating a
seg fault because it was being asked to process an input file with a
corrupt reloc section. The patch below fixes this by detecting
relocs with an out of range symbol index and issuing an error
message before causing the linker to terminate cleanly.
Is it OK to apply this patch ?
Cheers
Nick
2000-07-21 Nick Clifton <nickc@cygnus.com>
* elf32-mips.c (_bfd_mips_elf_check_relocs): Detect out of
range symbol indices in relocs and issue an error message.
Index: elf32-mips.c
===================================================================
RCS file: /cvs/src//src/bfd/elf32-mips.c,v
retrieving revision 1.74
diff -p -r1.74 elf32-mips.c
*** elf32-mips.c 2000/07/20 03:21:59 1.74
--- elf32-mips.c 2000/07/21 17:10:47
*************** _bfd_mips_elf_check_relocs (abfd, info,
*** 7593,7598 ****
--- 7593,7605 ----
if (r_symndx < extsymoff)
h = NULL;
+ else if (r_symndx >= extsymoff + (symtab_hdr->sh_size / symtab_hdr->sh_entsize))
+ {
+ (*_bfd_error_handler)
+ (_("Malformed reloc detected for section %s"), name);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
else
{
h = sym_hashes[r_symndx - extsymoff];