Fix potentially undefined behaviour use of strcpcy.

* pe-dll.c (pe_find_cdecl_alias_match): Use memmove to overwrite
	lname string.
This commit is contained in:
Nick Clifton 2021-03-16 14:02:38 +00:00
parent 012d442686
commit ee42883cff
2 changed files with 8 additions and 1 deletions

View File

@ -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> 2021-03-15 Jan Beulich <jbeulich@suse.com>
* pe-dll.c (generate_reloc): Drop padding to reloc_s->size. * pe-dll.c (generate_reloc): Drop padding to reloc_s->size.

View File

@ -3039,7 +3039,9 @@ pe_find_cdecl_alias_match (struct bfd_link_info *linfo, char *name)
if (pe_details->underscored) if (pe_details->underscored)
lname[0] = '_'; lname[0] = '_';
else 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; key.key = lname;
kv = bsearch (&key, udef_table, undef_count, kv = bsearch (&key, udef_table, undef_count,
sizeof (struct key_value), undef_sort_cmp); sizeof (struct key_value), undef_sort_cmp);