diff options
author | Nick Clifton <nickc@redhat.com> | 2016-05-09 17:31:07 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2016-05-09 17:31:07 +0100 |
commit | 315350be6598235df12a0190a5a4c21447eead36 (patch) | |
tree | ae9a90a664169c6c5a2d751226b9c2e083224442 /bfd | |
parent | 9239bbd3a6bf901dba1c0170622c50c78f6d1096 (diff) | |
download | gdb-315350be6598235df12a0190a5a4c21447eead36.zip gdb-315350be6598235df12a0190a5a4c21447eead36.tar.gz gdb-315350be6598235df12a0190a5a4c21447eead36.tar.bz2 |
Fix seg fault objdumping a corrupt binary with an invalid sh_link field.
PR binutils/20063
* elf.c (bfd_elf_get_elf_syms): Check for out of range sh_link
field before accessing sections array.
* readelf.c (get_32bit_section_headers): Warn if an out of range
sh_link or sh_info field is encountered.
(get_64bit_section_headers): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elf.c | 16 |
2 files changed, 17 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d5edec4..29dad01 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2016-05-09 Nick Clifton <nickc@redhat.com> + + PR binutils/20063 + * elf.c (bfd_elf_get_elf_syms): Check for out of range sh_link + field before accessing sections array. + 2016-05-09 Christophe Monat <christophe.monat@st.com> PR ld/20030 @@ -407,11 +407,17 @@ bfd_elf_get_elf_syms (bfd *ibfd, /* Find an index section that is linked to this symtab section. */ for (entry = elf_symtab_shndx_list (ibfd); entry != NULL; entry = entry->next) - if (sections[entry->hdr.sh_link] == symtab_hdr) - { - shndx_hdr = & entry->hdr; - break; - }; + { + /* PR 20063. */ + if (entry->hdr.sh_link >= elf_numsections (ibfd)) + continue; + + if (sections[entry->hdr.sh_link] == symtab_hdr) + { + shndx_hdr = & entry->hdr; + break; + }; + } if (shndx_hdr == NULL) { |