aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2017-11-22 12:22:11 +0000
committerYao Qi <yao.qi@linaro.org>2017-11-22 12:22:11 +0000
commit29f9a5673764c1b2711c0ceeba380a6ee764d1b2 (patch)
tree0708d6c0c9bb5b8894f8732ca952898c28cd78aa /gdb/gdbserver
parentdc958481429708ecf91f9b2c445063d43397f07e (diff)
downloadgdb-29f9a5673764c1b2711c0ceeba380a6ee764d1b2.zip
gdb-29f9a5673764c1b2711c0ceeba380a6ee764d1b2.tar.gz
gdb-29f9a5673764c1b2711c0ceeba380a6ee764d1b2.tar.bz2
Fix build with GCC 8: strncpy -> memcpy
Recent gcc 8 trunk emits the warning below, ../../../binutils-gdb/gdb/gdbserver/remote-utils.c:1204:14: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 6 bytes from a string of the same length [-Werror=stringop-truncation] strncpy (buf, "watch:", 6); ~~~~~~~~^~~~~~~~~~~~~~~~~~ ../../binutils-gdb/gdb/cli/cli-decode.c:1118:15: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] strncpy (cmdtype1 + 1, cmdtype, len - 1); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../binutils-gdb/gdb/cli/cli-decode.c:1110:16: note: length computed here len = strlen (cmdtype); ~~~~~~~^~~~~~~~~ ../../binutils-gdb/gdb/cli/cli-decode.c:1120:15: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] strncpy (cmdtype2, cmdtype, len - 1); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../binutils-gdb/gdb/cli/cli-decode.c:1110:16: note: length computed here len = strlen (cmdtype); ~~~~~~~^~~~~~~~~ ../../binutils-gdb/gdb/cp-namespace.c:1071:11: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 2 bytes from a string of the same length [-Werror=stringop-truncation] strncpy (full_name + scope_length, "::", 2); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This patch fixes it by using memcpy instead of strncpy. gdb: 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. gdb/gdbserver: 2017-11-22 Yao Qi <yao.qi@linaro.org> * remote-utils.c (prepare_resume_reply): Use memcpy.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog4
-rw-r--r--gdb/gdbserver/remote-utils.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index d891b2d..b53fe30 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,7 @@
+2017-11-22 Yao Qi <yao.qi@linaro.org>
+
+ * remote-utils.c (prepare_resume_reply): Use memcpy.
+
2017-11-19 Simon Marchi <simon.marchi@ericsson.com>
* linux-low.c (kill_one_lwp_callback): Return void, take
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 2e4888a..2fdbb6f 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -1173,7 +1173,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
CORE_ADDR addr;
int i;
- strncpy (buf, "watch:", 6);
+ memcpy (buf, "watch:", 6);
buf += 6;
addr = (*the_target->stopped_data_address) ();