* elf.c (bfd_elf_local_sym_name): Avoid crashes with invalid
authorJakub Jelinek <jakub@redhat.com>
Fri, 10 Dec 2004 13:08:03 +0000 (13:08 +0000)
committerJakub Jelinek <jakub@redhat.com>
Fri, 10 Dec 2004 13:08:03 +0000 (13:08 +0000)
st_shndx on STT_SECTION sections.

bfd/ChangeLog
bfd/elf.c

index d488fbb30b7e9ef8b95ac25c55386df825ec47cd..415356ddf5f3aa4da090f72d7ed343408e5c6dce 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-10  Jakub Jelinek  <jakub@redhat.com>
+
+       * elf.c (bfd_elf_local_sym_name): Avoid crashes with invalid
+       st_shndx on STT_SECTION sections.
+
 2004-12-09  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * elfcode.h (elf_slurp_reloc_table_from_section): Don't canonicalize
index c14b91a53c1c43ad14e731ced99eb28ed4e38d3d..2eef4baeecf83917e9e35e8ec9b741ee25c4cf4e 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -409,7 +409,10 @@ bfd_elf_local_sym_name (bfd *abfd, Elf_Internal_Sym *isym)
 {
   unsigned int iname = isym->st_name;
   unsigned int shindex = elf_tdata (abfd)->symtab_hdr.sh_link;
-  if (iname == 0 && ELF_ST_TYPE (isym->st_info) == STT_SECTION)
+  if (iname == 0 && ELF_ST_TYPE (isym->st_info) == STT_SECTION
+      /* Check for a bogus st_shndx to avoid crashing.  */
+      && isym->st_shndx < elf_numsections (abfd)
+      && !(isym->st_shndx >= SHN_LORESERVE && isym->st_shndx <= SHN_HIRESERVE))
     {
       iname = elf_elfsections (abfd)[isym->st_shndx]->sh_name;
       shindex = elf_elfheader (abfd)->e_shstrndx;