Misplaced parenthesis calculates two too few bytes for string
Alan Modra
amodra@gmail.com
Sun Dec 28 05:12:00 GMT 2014
More information about the Binutils mailing list
Sun Dec 28 05:12:00 GMT 2014
- Previous message (by thread): [PATCH, moxie] Limit moxie sto/ldo offsets to 16-bits.
- Next message (by thread): [PATCH] MIPS/binutils: microMIPS linker relaxation fixes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Factor out strlen. Better code and this style is far less likely
to suffer from misplaced parens.
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7b3a474..b883d3c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-28 Alan Modra <amodra@gmail.com>
+
+ PR 17766
+ * pei-x86_64.c (pex64_bfd_print_pdata_section): Correct string
+ length. Use memcpy rather than strcpy.
+
2014-12-26 Alan Modra <amodra@gmail.com>
PR 17755
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);
--
Alan Modra
Australia Development Lab, IBM
- Previous message (by thread): [PATCH, moxie] Limit moxie sto/ldo offsets to 16-bits.
- Next message (by thread): [PATCH] MIPS/binutils: microMIPS linker relaxation fixes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list