X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf-attrs.c;h=cd0cbcaa5556afecc6559e4a3ed51372e0514833;hb=fb167eb272279154dc2502614eb5331b01dc6ea4;hp=4237af58eb749ae840e02b0ffd6096c7e2f45740;hpb=45dfa85a1ee44000d43abb7945a4aa7631707563;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c index 4237af58eb..cd0cbcaa55 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, 2012 - 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 @@ -446,7 +449,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) len = hdr->sh_size - 1; while (len > 0) { - int namelen; + unsigned namelen; bfd_vma section_len; int vendor; @@ -455,8 +458,11 @@ _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; + 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)