This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix build with GCC 8: strncpy ->strcpy


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

commit a9f26f609e3a1b6ae3aab300b55442e0a81e2bce
Author: Yao Qi <yao.qi@linaro.org>
Date:   Wed Nov 22 12:22:11 2017 +0000

    Fix build with GCC 8: strncpy ->strcpy
    
    Recent gcc 8 trunk emits the warning below,
    
    ../../binutils-gdb/gdb/python/py-gdb-readline.c:79:15: error: â??char* strncpy(char*, const char*, size_t)â?? output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
           strncpy (q, p, n);
           ~~~~~~~~^~~~~~~~~
    ../../binutils-gdb/gdb/python/py-gdb-readline.c:73:14: note: length computed here
       n = strlen (p);
           ~~~~~~~^~~
    
    gdb:
    
    2017-11-22  Yao Qi  <yao.qi@linaro.org>
    
    	* python/py-gdb-readline.c (gdbpy_readline_wrapper): Use strcpy.

Diff:
---
 gdb/ChangeLog                | 4 ++++
 gdb/python/py-gdb-readline.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a9e7528..63ae72e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2017-11-22  Yao Qi  <yao.qi@linaro.org>
 
+	* python/py-gdb-readline.c (gdbpy_readline_wrapper): Use strcpy.
+
+2017-11-22  Yao Qi  <yao.qi@linaro.org>
+
 	* cli/cli-decode.c (help_list): Use memcpy instead of strncpy.
 	* cp-namespace.c (cp_lookup_transparent_type_loop): Likewise.
 
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
index a02fa8c..ab14b8c 100644
--- a/gdb/python/py-gdb-readline.c
+++ b/gdb/python/py-gdb-readline.c
@@ -76,7 +76,7 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
   q = (char *) PyMem_RawMalloc (n + 2);
   if (q != NULL)
     {
-      strncpy (q, p, n);
+      strcpy (q, p);
       q[n] = '\n';
       q[n + 1] = '\0';
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]