aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorChen Gang <gang.chen.5i5j@gmail.com>2014-08-07 15:36:36 +0930
committerAlan Modra <amodra@gmail.com>2014-08-07 15:41:46 +0930
commit7f59d2acb6971695c36a73ce4a061cdc4b892f29 (patch)
tree674cdd394f9b1c524fd01ed866e7eab59934a243 /bfd
parentdb7129469b10a701659f0e38e3edeb2191236831 (diff)
downloadgdb-7f59d2acb6971695c36a73ce4a061cdc4b892f29.zip
gdb-7f59d2acb6971695c36a73ce4a061cdc4b892f29.tar.gz
gdb-7f59d2acb6971695c36a73ce4a061cdc4b892f29.tar.bz2
Ensure coff-ppc local symbols are zero terminated
* coff-ppc.c (coff_ppc_relocate_section): Ensure local symbols are zero terminated.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/coff-ppc.c19
2 files changed, 16 insertions, 8 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index edbcffa..d85f409 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-07 Chen Gang <gang.chen.5i5j@gmail.com>
+
+ * coff-ppc.c (coff_ppc_relocate_section): Ensure local symbols are
+ zero terminated.
+
2014-08-07 H.J. Lu <hongjiu.lu@intel.com>
Alan Modra <amodra@gmail.com>
diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c
index 3c39afa..32d3012 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;