[binutils-gdb] Fix another strncpy warning

Alan Modra amodra@sourceware.org
Sat Jun 19 01:39:09 GMT 2021


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

commit d984392e752c43ec226a9d0df23af0c743e2b411
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jun 18 22:25:10 2021 +0930

    Fix another strncpy warning
    
            * tic30-dis.c (get_register_operand): Don't ask strncpy to fill
            entire buffer.

Diff:
---
 opcodes/ChangeLog   | 5 +++++
 opcodes/tic30-dis.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 8f4b9768343..f262529d566 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-19  Alan Modra  <amodra@gmail.com>
+
+	* tic30-dis.c (get_register_operand): Don't ask strncpy to fill
+	entire buffer.
+
 2021-06-17  Alan Modra  <amodra@gmail.com>
 
 	* ppc-opc.c (powerpc_opcodes): Move cell db*cyc to proper location
diff --git a/opcodes/tic30-dis.c b/opcodes/tic30-dis.c
index bb96c07e712..a78a0dad218 100644
--- a/opcodes/tic30-dis.c
+++ b/opcodes/tic30-dis.c
@@ -201,7 +201,7 @@ get_register_operand (unsigned char fragment, char *buffer)
     {
       if ((fragment & 0x1F) == current_reg->opcode)
 	{
-	  strncpy (buffer, current_reg->name, OPERAND_BUFFER_LEN);
+	  strncpy (buffer, current_reg->name, OPERAND_BUFFER_LEN - 1);
 	  buffer[OPERAND_BUFFER_LEN - 1] = 0;
 	  return 1;
 	}


More information about the Binutils-cvs mailing list