From: Ian Lance Taylor Date: Tue, 22 Jun 1999 21:25:49 +0000 (+0000) Subject: * elf.c (bfd_section_from_shdr): Avoid crashing on a bogus sh_link X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=03ae5f594ecda3eccaa441dd8454889379980c1d;p=binutils-gdb.git * elf.c (bfd_section_from_shdr): Avoid crashing on a bogus sh_link field. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index aa2ebec5b27..8fd1e582968 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +1999-06-23 Ian Lance Taylor + + * elf.c (bfd_section_from_shdr): Avoid crashing on a bogus sh_link + field. + 1999-06-22 Ian Lance Taylor From Franz Sirl : diff --git a/bfd/elf.c b/bfd/elf.c index 1ce4d91a233..ac5a2153ef3 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -1201,6 +1201,15 @@ bfd_section_from_shdr (abfd, shindex) asection *target_sect; Elf_Internal_Shdr *hdr2; + /* Check for a bogus link to avoid crashing. */ + if (hdr->sh_link >= ehdr->e_shnum) + { + ((*_bfd_error_handler) + (_("%s: invalid link %lu for reloc section %s (index %u)"), + bfd_get_filename (abfd), hdr->sh_link, name, shindex)); + return _bfd_elf_make_section_from_shdr (abfd, hdr, name); + } + /* For some incomprehensible reason Oracle distributes libraries for Solaris in which some of the objects have bogus sh_link fields. It would be nice if we could just