From: Chen Gang Date: Thu, 7 Aug 2014 06:06:36 +0000 (+0930) Subject: Ensure coff-ppc local symbols are zero terminated X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7f59d2acb6971695c36a73ce4a061cdc4b892f29;p=binutils-gdb.git Ensure coff-ppc local symbols are zero terminated * coff-ppc.c (coff_ppc_relocate_section): Ensure local symbols are zero terminated. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index edbcffa6e79..d85f409da88 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2014-08-07 Chen Gang + + * coff-ppc.c (coff_ppc_relocate_section): Ensure local symbols are + zero terminated. + 2014-08-07 H.J. Lu Alan Modra diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c index 3c39afae7a8..32d30120d45 100644 --- a/bfd/coff-ppc.c +++ b/bfd/coff-ppc.c @@ -1073,10 +1073,11 @@ coff_ppc_relocate_section (bfd *output_bfd, { /* It is a file local symbol. */ int *local_toc_table; - const char *name; + char name[SYMNMLEN + 1]; sym = syms + symndx; - name = sym->_n._n_name; + strncpy (name, sym->_n._n_name, SYMNMLEN); + name[SYMNMLEN] = '\0'; local_toc_table = obj_coff_local_toc_table(input_bfd); our_toc_offset = local_toc_table[symndx]; @@ -1225,9 +1226,14 @@ coff_ppc_relocate_section (bfd *output_bfd, case IMAGE_REL_PPC_ABSOLUTE: { const char *my_name; + char buf[SYMNMLEN + 1]; if (h == 0) - my_name = (syms+symndx)->_n._n_name; + { + strncpy (buf, (syms+symndx)->_n._n_name, SYMNMLEN); + buf[SYMNMLEN] = '\0'; + my_name = buf; + } else my_name = h->root.root.root.string; @@ -1288,11 +1294,8 @@ coff_ppc_relocate_section (bfd *output_bfd, } if (h == 0) - { - /* It is a file local symbol. */ - sym = syms + symndx; - name = sym->_n._n_name; - } + /* It is a file local symbol. */ + sym = syms + symndx; else { char *target = 0;