aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-02-14 07:03:11 -0700
committerTom Tromey <tromey@adacore.com>2023-02-14 09:01:18 -0700
commit81aa19c303c94f549cb9ae343cfe4b635b4e888c (patch)
tree804ffe2eec706e0e18732b5724ebcf5d737f9e7a /gdbserver
parent5bed9dc992a0136d403a7addb29a2ed822fd4fd2 (diff)
downloadgdb-81aa19c303c94f549cb9ae343cfe4b635b4e888c.zip
gdb-81aa19c303c94f549cb9ae343cfe4b635b4e888c.tar.gz
gdb-81aa19c303c94f549cb9ae343cfe4b635b4e888c.tar.bz2
Do not cast away const in agent_run_command
While investigating something else, I noticed some weird code in agent_run_command (use of memcpy rather than strcpy). Then I noticed that 'cmd' is used as both an in and out parameter, despite being const. Casting away const like this is bad. This patch removes the const and fixes the memcpy. I also added a static assert to assure myself that the code in gdbserver is correct -- gdbserver is passing its own buffer directly to agent_run_command. Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdbserver')
-rw-r--r--gdbserver/server.cc5
-rw-r--r--gdbserver/tracepoint.cc2
2 files changed, 6 insertions, 1 deletions
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 21fb51a..46dfe70 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -51,6 +51,11 @@
#include "gdbsupport/scoped_restore.h"
#include "gdbsupport/search.h"
+/* PBUFSIZ must also be at least as big as IPA_CMD_BUF_SIZE, because
+ the client state data is passed directly to some agent
+ functions. */
+gdb_static_assert (PBUFSIZ >= IPA_CMD_BUF_SIZE);
+
#define require_running_or_return(BUF) \
if (!target_running ()) \
{ \
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 37a9a8c..b59077a 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -6820,7 +6820,7 @@ run_inferior_command (char *cmd, int len)
target_pause_all (false);
uninsert_all_breakpoints ();
- err = agent_run_command (pid, (const char *) cmd, len);
+ err = agent_run_command (pid, cmd, len);
reinsert_all_breakpoints ();
target_unpause_all (false);