diff options
author | Alan Modra <amodra@gmail.com> | 2014-12-28 15:28:19 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2014-12-28 15:34:01 +1030 |
commit | de0d78958fe3db5184c5a7174f55f08d41c8706b (patch) | |
tree | 64ae2b93a4c00849e1cc9731b4d89d97972bce55 /bfd/pei-x86_64.c | |
parent | ce637ffbe6b75a4a676bbf5f68434abf5261ba99 (diff) | |
download | gdb-de0d78958fe3db5184c5a7174f55f08d41c8706b.zip gdb-de0d78958fe3db5184c5a7174f55f08d41c8706b.tar.gz gdb-de0d78958fe3db5184c5a7174f55f08d41c8706b.tar.bz2 |
Misplaced parenthesis calculates two too few bytes for string
Factor out strlen to give better code and less likelihood of a repeat
of this problem.
PR 17766
* pei-x86_64.c (pex64_bfd_print_pdata_section): Correct string
length. Use memcpy rather than strcpy.
Diffstat (limited to 'bfd/pei-x86_64.c')
-rw-r--r-- | bfd/pei-x86_64.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bfd/pei-x86_64.c b/bfd/pei-x86_64.c index 51bf390..2009a29 100644 --- a/bfd/pei-x86_64.c +++ b/bfd/pei-x86_64.c @@ -601,11 +601,12 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section) section name, replacing .pdata by .xdata prefix. */ if (strcmp (pdata_section->name, ".pdata") != 0) { - char *xdata_name = alloca (strlen (pdata_section->name + 1)); + size_t len = strlen (pdata_section->name); + char *xdata_name = alloca (len + 1); - xdata_name = strcpy (xdata_name, pdata_section->name); + xdata_name = memcpy (xdata_name, pdata_section->name, len + 1); /* Transform .pdata prefix into .xdata prefix. */ - if (strlen (xdata_name) > 1) + if (len > 1) xdata_name [1] = 'x'; xdata_section = pex64_get_section_by_rva (abfd, xdata_base, xdata_name); |