2017-11-10 Martin Sebor * gdb/cli/cli-decode.c (help_list): Use strcpy and memcpy instead of strncpy. * gdb/cp-namespace.c (cp_lookup_transparent_type_loop): Use strcpy instead of strncpy to avoid -Wstringop-truncation. * gdb/gdbserver/remote-utils.c (prepare_resume_reply): Use memcpy instead of strncpy to avoid -Wstringop-truncation. diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 87ebed5..968779e 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1,4 +1,4 @@ -/* Handle lists of commands, their decoding and documentation, for GDB. +t/* Handle lists of commands, their decoding and documentation, for GDB. Copyright (C) 1986-2017 Free Software Foundation, Inc. @@ -1115,9 +1115,8 @@ help_list (struct cmd_list_element *list, const char *cmdtype, if (len) { cmdtype1[0] = ' '; - strncpy (cmdtype1 + 1, cmdtype, len - 1); - cmdtype1[len] = 0; - strncpy (cmdtype2, cmdtype, len - 1); + strcpy (cmdtype1 + 1, cmdtype); + memcpy (cmdtype2, cmdtype, len - 1); strcpy (cmdtype2 + len - 1, " sub"); } diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 214b7e1..fabe87a 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -1068,7 +1068,7 @@ cp_lookup_transparent_type_loop (const char *name, full_name = (char *) alloca (scope_length + 2 + strlen (name) + 1); strncpy (full_name, scope, scope_length); - strncpy (full_name + scope_length, "::", 2); + strcpy (full_name + scope_length, "::"); strcpy (full_name + scope_length + 2, name); return basic_lookup_transparent_type (full_name); diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index 66e0652..e314447 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -1201,7 +1201,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) ();