aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2021-03-16 14:02:38 +0000
committerNick Clifton <nickc@redhat.com>2021-03-16 14:02:59 +0000
commitee42883cff56a3fb6fb4ff939dd3c8c4f42d4c12 (patch)
tree76cde264402b4677f2c10c65e5cb634cd617acd8 /ld
parent012d44268695f1c5d4e2e019c610c8b99bd7e553 (diff)
downloadgdb-ee42883cff56a3fb6fb4ff939dd3c8c4f42d4c12.zip
gdb-ee42883cff56a3fb6fb4ff939dd3c8c4f42d4c12.tar.gz
gdb-ee42883cff56a3fb6fb4ff939dd3c8c4f42d4c12.tar.bz2
Fix potentially undefined behaviour use of strcpcy.
* pe-dll.c (pe_find_cdecl_alias_match): Use memmove to overwrite lname string.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog5
-rw-r--r--ld/pe-dll.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 01b93c5..7cc917a 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2021-03-16 Nick Clifton <nickc@redhat.com>
+
+ * pe-dll.c (pe_find_cdecl_alias_match): Use memmove to overwrite
+ lname string.
+
2021-03-15 Jan Beulich <jbeulich@suse.com>
* pe-dll.c (generate_reloc): Drop padding to reloc_s->size.
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index eaecb95..7aba09c 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -3039,7 +3039,9 @@ pe_find_cdecl_alias_match (struct bfd_link_info *linfo, char *name)
if (pe_details->underscored)
lname[0] = '_';
else
- strcpy (lname, lname + 1);
+ /* Use memmove rather than strcpy as that
+ can handle overlapping buffers. */
+ memmove (lname, lname + 1, strlen (lname));
key.key = lname;
kv = bsearch (&key, udef_table, undef_count,
sizeof (struct key_value), undef_sort_cmp);