aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf-attrs.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-08-08 13:20:02 +0100
committerNick Clifton <nickc@redhat.com>2017-08-08 13:20:02 +0100
commit24d3e51bf0612c6cf5e9a824b982e7ed38e741c8 (patch)
tree41211d49485296da41b24791dc5f4caba61f734f /bfd/elf-attrs.c
parent1fea592a7dc4c6639ad21321a2cf7b1f0bb55592 (diff)
downloadgdb-24d3e51bf0612c6cf5e9a824b982e7ed38e741c8.zip
gdb-24d3e51bf0612c6cf5e9a824b982e7ed38e741c8.tar.gz
gdb-24d3e51bf0612c6cf5e9a824b982e7ed38e741c8.tar.bz2
Fix address violation problems when parsing corrupt ELF binaries.
PR 21916 * elf-attrs.c (_bfd_elf_parse_attributes): Complain about very small section lengths. * elf.c (_bfd_elf_setup_sections): Skip empty entries in the group table. (elfcore_grok_freebsd_prstatus): Add checks to make sure that there is enough data present in the note.
Diffstat (limited to 'bfd/elf-attrs.c')
-rw-r--r--bfd/elf-attrs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
index def1345..759da6e 100644
--- a/bfd/elf-attrs.c
+++ b/bfd/elf-attrs.c
@@ -468,6 +468,12 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
if (section_len > len)
section_len = len;
len -= section_len;
+ if (section_len <= 4)
+ {
+ _bfd_error_handler (_("%B: error: attribute section length too small: %ld"),
+ abfd, section_len);
+ break;
+ }
section_len -= 4;
namelen = strnlen ((char *) p, section_len) + 1;
if (namelen == 0 || namelen >= section_len)