From: Will Newton Date: Wed, 5 Nov 2014 15:24:30 +0000 (+0000) Subject: bfd/elf-attrs.c: Fix possible infinite loop parsing attributes X-Git-Tag: hjl/linux/release/2.25.51.0.1~3^2~44^2~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fe9dc4519a86b856da7de0837366bbece82f2de;p=thirdparty%2Fbinutils-gdb.git 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 * elf-attrs.c (_bfd_elf_parse_attributes): Handle zero length sections and sub-sections. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 16724b3cb52..7a57b1265f9 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2014-11-06 Will Newton + + * elf-attrs.c (_bfd_elf_parse_attributes): Handle zero + length sections and sub-sections. + 2014-11-04 Nick Clifton PR binutils/17512 diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c index cd0cbcaa555..6bc2944c7bf 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;