From: Andreas Schwab Date: Mon, 20 Aug 2018 14:55:05 +0000 (+0200) Subject: Fix invalid strcpy on unterminated buffer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9dcbfff1e02778bac6fb723640724c38001a8f0a;p=binutils-gdb.git Fix invalid strcpy on unterminated buffer * read.c (do_repeat_with_expander): Use memmove instead of strcpy on unterminated string buffer. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 366f4c111cf..5343503667c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2018-08-21 Andreas Schwab + + * read.c (do_repeat_with_expander): Use memmove instead of strcpy + on unterminated string buffer. + 2018-08-21 Alan Modra * config/tc-ppc.c (md_assemble): Delay counting of optional diff --git a/gas/read.c b/gas/read.c index 1f211b6819b..f011149bb36 100644 --- a/gas/read.c +++ b/gas/read.c @@ -3117,7 +3117,8 @@ do_repeat_with_expander (size_t count, sub = strstr (processed.ptr, expander); len = sprintf (sub, "%lu", (unsigned long) count); gas_assert (len < 8); - strcpy (sub + len, sub + 8); + memmove (sub + len, sub + 8, + processed.ptr + processed.len - (sub + 8)); processed.len -= (8 - len); sb_add_sb (& many, & processed); sb_kill (& processed);