[binutils-gdb/binutils-2_29-branch] Fix memory corruption when using memcpy to overwtite a string in place.

Nick Clifton nickc@sourceware.org
Thu Feb 22 14:39:00 GMT 2018


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=96a94bd954f0e1078ed214b5f68de5a28ec6a8c6

commit 96a94bd954f0e1078ed214b5f68de5a28ec6a8c6
Author: A. Wilcox <awilfox@adelielinux.org>
Date:   Thu Feb 22 13:00:36 2018 +0000

    Fix memory corruption when using memcpy to overwtite a string in place.
    
    	PR 22014
    	* config/tc-mips.c (mips_lookup_insn): Use memmove to strip the
    	instruction size suffix.

Diff:
---
 gas/ChangeLog        | 6 ++++++
 gas/config/tc-mips.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 6eb20f0..3a0bbd7 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-22  A. Wilcox  <awilfox@adelielinux.org>
+
+	PR 22014
+	* config/tc-mips.c (mips_lookup_insn): Use memmove to strip the
+	instruction size suffix.
+
 2017-12-12  Alan Modra  <amodra@gmail.com>
 
 	PR 21118
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 618de6c..1727996 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -13956,7 +13956,7 @@ mips_lookup_insn (struct hash_control *hash, const char *start,
 	suffix = 0;
       if (suffix)
 	{
-	  memcpy (name + opend - 2, name + opend, length - opend + 1);
+	  memmove (name + opend - 2, name + opend, length - opend + 1);
 	  insn = (struct mips_opcode *) hash_find (hash, name);
 	  if (insn)
 	    {



More information about the Binutils-cvs mailing list