This is the mail archive of the
gdb-testers@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix build with GCC 8: strncpy -> memcpy
- From: sergiodj+buildbot at sergiodj dot net
- To: gdb-testers at sourceware dot org
- Date: Wed, 22 Nov 2017 07:42:47 -0500
- Subject: [binutils-gdb] Fix build with GCC 8: strncpy -> memcpy
- Authentication-results: sourceware.org; auth=none
*** TEST RESULTS FOR COMMIT 29f9a5673764c1b2711c0ceeba380a6ee764d1b2 ***
Author: Yao Qi <yao.qi@linaro.org>
Branch: master
Commit: 29f9a5673764c1b2711c0ceeba380a6ee764d1b2
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.
- Follow-Ups:
- Failures on Fedora-x86_64-native-gdbserver-m32, branch master
- Failures on Ubuntu-AArch32-native-extended-gdbserver-m32, branch master
- Failures on Fedora-s390x-m64, branch master
- Failures on Ubuntu-AArch64-native-gdbserver-m64, branch master
- Failures on Fedora-x86_64-cc-with-index, branch master
- Failures on Fedora-x86_64-native-extended-gdbserver-m32, branch master
- Failures on Ubuntu-AArch32-native-gdbserver-m32, branch master
- Failures on Fedora-i686, branch master
- Failures on Fedora-x86_64-m32, branch master
- Failures on Ubuntu-AArch64-m64, branch master