aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2014-01-20 20:56:13 +0800
committerYao Qi <yao@codesourcery.com>2014-02-05 20:25:47 +0800
commit8dc5b31971ad5dddf5e6efa07cf70d094c1a9fe5 (patch)
treebc4a4c5e809bfda5c1feff8d3228b7e7a80b32f8 /gdb
parentde7b2893853cd1122b223a2023fdc35b41a26960 (diff)
downloadgdb-8dc5b31971ad5dddf5e6efa07cf70d094c1a9fe5.zip
gdb-8dc5b31971ad5dddf5e6efa07cf70d094c1a9fe5.tar.gz
gdb-8dc5b31971ad5dddf5e6efa07cf70d094c1a9fe5.tar.bz2
Use rs->buf after getpkt
Hi, The following code snippet looks wrong to me char *buf = rs->buf; getpkt (&rs->buf, &rs->buf_size, 0); packet_ok (buf, ); if rs->buf is reallocated in getpkt, buf points to an out of dated memory. This patch removes local 'buf' and uses rs->buf. gdb: 2014-02-05 Yao Qi <yao@codesourcery.com> * remote.c (remote_pass_signals): Remove local 'buf' and use rs->buf. (remote_program_signals): Likewise.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/remote.c8
2 files changed, 8 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 73e8774..a6fa6fc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2014-02-05 Yao Qi <yao@codesourcery.com>
+ * remote.c (remote_pass_signals): Remove local 'buf' and use
+ rs->buf.
+ (remote_program_signals): Likewise.
+
+2014-02-05 Yao Qi <yao@codesourcery.com>
+
* ctf.c: Include "inferior.h" and "gdbthread.h".
(CTF_PID): A new macro.
(ctf_open): Call inferior_appeared and add_thread_silent.
diff --git a/gdb/remote.c b/gdb/remote.c
index 4227ed5..e1d0a64 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1732,11 +1732,9 @@ remote_pass_signals (int numsigs, unsigned char *pass_signals)
*p = 0;
if (!rs->last_pass_packet || strcmp (rs->last_pass_packet, pass_packet))
{
- char *buf = rs->buf;
-
putpkt (pass_packet);
getpkt (&rs->buf, &rs->buf_size, 0);
- packet_ok (buf, &remote_protocol_packets[PACKET_QPassSignals]);
+ packet_ok (rs->buf, &remote_protocol_packets[PACKET_QPassSignals]);
if (rs->last_pass_packet)
xfree (rs->last_pass_packet);
rs->last_pass_packet = pass_packet;
@@ -1785,11 +1783,9 @@ remote_program_signals (int numsigs, unsigned char *signals)
if (!rs->last_program_signals_packet
|| strcmp (rs->last_program_signals_packet, packet) != 0)
{
- char *buf = rs->buf;
-
putpkt (packet);
getpkt (&rs->buf, &rs->buf_size, 0);
- packet_ok (buf, &remote_protocol_packets[PACKET_QProgramSignals]);
+ packet_ok (rs->buf, &remote_protocol_packets[PACKET_QProgramSignals]);
xfree (rs->last_program_signals_packet);
rs->last_program_signals_packet = packet;
}