2001-04-26 H.J. Lu <hjl@gnu.org>
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 26 Apr 2001 19:09:20 +0000 (19:09 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 26 Apr 2001 19:09:20 +0000 (19:09 +0000)
* elf32-i386.c (elf_i386_check_relocs): Verify if r_symndx is
valid.

bfd/ChangeLog
bfd/elf32-i386.c

index 17ec1b673836f15420911ba2f58c791e03bc6136..37ffb671e345469e43e3197c9c24984c43e16743 100644 (file)
@@ -1,3 +1,8 @@
+2001-04-26  H.J. Lu  <hjl@gnu.org>
+
+       * elf32-i386.c (elf_i386_check_relocs): Verify if r_symndx is
+       valid.
+
 2001-04-25  Frank Ch. Eigler  <fche@redhat.com>
 
        * bfd-in.h (bfd_cache_close): Declare newly exported function.
index 658c86deb1c2e3bfcab0f20a4aead15c6a884a82..f4e1e500c320e2cb8203abc88e21b993c1e744b9 100644 (file)
@@ -501,6 +501,20 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
 
       r_symndx = ELF32_R_SYM (rel->r_info);
 
+      if (r_symndx >= symtab_hdr->sh_size / symtab_hdr->sh_entsize)
+       {
+         if (abfd->my_archive)
+           (*_bfd_error_handler) (_("%s(%s): bad symbol index: %d"),
+                                  bfd_get_filename (abfd->my_archive),
+                                  bfd_get_filename (abfd),
+                                  r_symndx);
+         else
+           (*_bfd_error_handler) (_("%s: bad symbol index: %d"),
+                                  bfd_get_filename (abfd),
+                                  r_symndx);
+         return false;
+       }
+
       if (r_symndx < symtab_hdr->sh_info)
        h = NULL;
       else
@@ -686,7 +700,7 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
                        (*_bfd_error_handler) (_("%s: bad relocation section name `%s\'"),
                                               bfd_get_filename (abfd),
                                               name);
-                 }
+                   }
 
                  sreloc = bfd_get_section_by_name (dynobj, name);
                  if (sreloc == NULL)