diff options
author | Will Newton <will.newton@linaro.org> | 2014-11-05 15:24:30 +0000 |
---|---|---|
committer | Will Newton <will.newton@linaro.org> | 2014-11-06 13:01:18 +0000 |
commit | 1fe9dc4519a86b856da7de0837366bbece82f2de (patch) | |
tree | 5eb97c8baeeb6f2cc967070b1952d8b545abe9d6 /bfd/elf-attrs.c | |
parent | f321b0377203a27f3ee54bf8e0d613e8404e9c6b (diff) | |
download | gdb-1fe9dc4519a86b856da7de0837366bbece82f2de.zip gdb-1fe9dc4519a86b856da7de0837366bbece82f2de.tar.gz gdb-1fe9dc4519a86b856da7de0837366bbece82f2de.tar.bz2 |
bfd/elf-attrs.c: Fix possible infinite loop parsing attributes
Handle the case of a zero length section or sub-section in
_bfd_elf_parse_attributes and in doing so prevent an infinite loop
in the parser.
bfd/ChangeLog:
2014-11-06 Will Newton <will.newton@linaro.org>
* elf-attrs.c (_bfd_elf_parse_attributes): Handle zero
length sections and sub-sections.
Diffstat (limited to 'bfd/elf-attrs.c')
-rw-r--r-- | bfd/elf-attrs.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c index cd0cbca..6bc2944 100644 --- a/bfd/elf-attrs.c +++ b/bfd/elf-attrs.c @@ -455,6 +455,8 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) section_len = bfd_get_32 (abfd, p); p += 4; + if (section_len == 0) + break; if (section_len > len) section_len = len; len -= section_len; @@ -487,6 +489,8 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) p += n; subsection_len = bfd_get_32 (abfd, p); p += 4; + if (subsection_len == 0) + break; if (subsection_len > section_len) subsection_len = section_len; section_len -= subsection_len; |