https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=d7db69fbf482149e18ed1977df41fe320f5cbef2
commit d7db69fbf482149e18ed1977df41fe320f5cbef2
Author: Mark Wielaard <ma...@kl...>
Date: Thu Nov 14 12:25:27 2024 +0100
coregrind/m_gdbserver/remote-utils.c (prepare_resume_reply): Use memcpy
GCC8 (but apparently not later versions) complain about the use of
strncpy when not actually copying a string:
remote-utils.c:1140:14: warning: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying 6 bytes from a string of the same length [-Wstringop-truncation]
strncpy (buf, "watch:", 6);
~~~~~~~~^~~~~~~~~~~~~~~~~~
This is "harmless" because buf is large enough and we will add more
chars (including a zero terminator) later. But using strncpy here is a
bit odd because we don't really want to copy a string, but an array of
6 chars. So use memcpy here to do so, simplyfing the code.
Diff:
---
coregrind/m_gdbserver/remote-utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/coregrind/m_gdbserver/remote-utils.c b/coregrind/m_gdbserver/remote-utils.c
index b22dc4482b..8dfc768d49 100644
--- a/coregrind/m_gdbserver/remote-utils.c
+++ b/coregrind/m_gdbserver/remote-utils.c
@@ -1137,7 +1137,7 @@ void prepare_resume_reply (char *buf, char status, unsigned char sig)
CORE_ADDR addr;
int i;
- strncpy (buf, "watch:", 6);
+ VG_(memcpy) (buf, "watch:", 6);
buf += 6;
addr = valgrind_stopped_data_address ();
|