(bfd_section_from_shdr): Add sanity check when parsing dynamic sections.
authorNick Clifton <nickc@redhat.com>
Tue, 17 May 2005 16:23:26 +0000 (16:23 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 17 May 2005 16:23:26 +0000 (16:23 +0000)
bfd/ChangeLog
bfd/elf.c

index 3d2b2d9b230b3a43e99f4df3da5a5df7ff4ddfd6..feb815ffe9dd78493b0ce01e7f4bdc6b91c923e6 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-17  Tavis Ormandy <taviso@gentoo.org>
+
+       * elf.c (bfd_section_from_shdr): Add sanity check when parsing
+       dynamic sections.
+
 2005-05-17  Alan Modra  <amodra@bigpond.net.au>
 
        * elf32-ppc.c (LIS_11. LIS_12): Define.
index 8e087e32dc352e78c7b3ca25e76b2c26f81357d7..f77d626a30dd6e544e9c92c24306e8aebca76179 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1768,6 +1768,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
     case SHT_DYNAMIC:  /* Dynamic linking information.  */
       if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
        return FALSE;
+      if (hdr->sh_link > elf_numsections (abfd)
+         || elf_elfsections (abfd)[hdr->sh_link] == NULL)
+       return FALSE;
       if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
        {
          Elf_Internal_Shdr *dynsymhdr;