Fix address violation problems when parsing corrupt ELF binaries.
[deliverable/binutils-gdb.git] / bfd / elf-attrs.c
index def1345eeb00396decdca83cf56b40e19736e379..759da6e968eb51b47c9e47ff62f21033f7707b0e 100644 (file)
@@ -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)
This page took 0.025009 seconds and 4 git commands to generate.