X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bfd%2Felf-attrs.c;h=cd0cbcaa5556afecc6559e4a3ed51372e0514833;hb=a71c9b7687b40ba8a2ea22da26c712522e21fe7b;hp=569e846cc5474605fdcc5b941d1ecd994e8ca605;hpb=e1a6b26358dae2f75ccb8b57466ad9fa6cf1ed2f;p=platform%2Fupstream%2Fbinutils.git diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c index 569e846..cd0cbca 100644 --- a/bfd/elf-attrs.c +++ b/bfd/elf-attrs.c @@ -1,6 +1,5 @@ /* ELF attributes support (based on ARM EABI attributes). - Copyright 2005, 2006, 2007, 2009, 2010 - Free Software Foundation, Inc. + Copyright (C) 2005-2014 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -347,6 +346,10 @@ _bfd_elf_copy_obj_attributes (bfd *ibfd, bfd *obfd) int i; int vendor; + if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour + || bfd_get_flavour (obfd) != bfd_target_elf_flavour) + return; + for (vendor = OBJ_ATTR_FIRST; vendor <= OBJ_ATTR_LAST; vendor++) { in_attr @@ -428,7 +431,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) bfd_byte *contents; bfd_byte *p; bfd_vma len; - const char *std_section; + const char *std_sec; contents = (bfd_byte *) bfd_malloc (hdr->sh_size); if (!contents) @@ -440,13 +443,13 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) return; } p = contents; - std_section = get_elf_backend_data (abfd)->obj_attrs_vendor; + std_sec = get_elf_backend_data (abfd)->obj_attrs_vendor; if (*(p++) == 'A') { len = hdr->sh_size - 1; while (len > 0) { - int namelen; + unsigned namelen; bfd_vma section_len; int vendor; @@ -455,11 +458,14 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) if (section_len > len) section_len = len; len -= section_len; - namelen = strlen ((char *)p) + 1; - section_len -= namelen + 4; - if (std_section && strcmp ((char *)p, std_section) == 0) + section_len -= 4; + namelen = strnlen ((char *) p, section_len) + 1; + if (namelen == 0 || namelen >= section_len) + break; + section_len -= namelen; + if (std_sec && strcmp ((char *) p, std_sec) == 0) vendor = OBJ_ATTR_PROC; - else if (strcmp ((char *)p, "gnu") == 0) + else if (strcmp ((char *) p, "gnu") == 0) vendor = OBJ_ATTR_GNU; else {