]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Do not cast away const in agent_run_command
authorTom Tromey <tromey@adacore.com>
Tue, 14 Feb 2023 14:03:11 +0000 (07:03 -0700)
committerTom Tromey <tromey@adacore.com>
Tue, 14 Feb 2023 16:01:18 +0000 (09:01 -0700)
commit81aa19c303c94f549cb9ae343cfe4b635b4e888c
tree804ffe2eec706e0e18732b5724ebcf5d737f9e7a
parent5bed9dc992a0136d403a7addb29a2ed822fd4fd2
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>
gdb/linux-nat.c
gdbserver/server.cc
gdbserver/tracepoint.cc
gdbsupport/agent.cc
gdbsupport/agent.h