* [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet
@ 2026-11-16 11:10 Andrew Burgess
2026-11-16 11:10 ` [PATCH 1/5] gdbserver: clean up some older code in tracepoint.cc Andrew Burgess
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Andrew Burgess @ 2026-11-16 11:10 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
This started as a simple patch to fix a buffer overflow in QTDPsrc
(patch #2). But grew a little along the way.
Patch #1 is a general spring clean of the code I ended up touching.
Then patches #3, #4, and #5 fix additional issues that I spotted along
the way.
There is undoubtedly other similar bugs in the gdbserver code, but I
really wanted to limit the size of this series, so I've cut myself off
here. I suspect I'll follow up with a few additional fixes over the
next few weeks.
Thanks,
Andrew
--
Andrew Burgess (5):
gdbserver: clean up some older code in tracepoint.cc
gdbserver: prevent buffer overrun for QTDPsrc packet
gdbserver: improve packet parsing in tracepoint.cc
gdbserver: don't leak trace variable names if reusing variable numbers
gdbserver: use unique_xmalloc_ptr to avoid memory leaks
.../gdb.server/invalid-tracepoint-packets.exp | 453 ++++++++++++++++++
gdbserver/tracepoint.cc | 434 +++++++++++------
2 files changed, 735 insertions(+), 152 deletions(-)
create mode 100644 gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
base-commit: 5678a7bfceb3a6ea18bcde1ae68f7e96c43c998b
--
2.25.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/5] gdbserver: clean up some older code in tracepoint.cc
2026-11-16 11:10 [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet Andrew Burgess
@ 2026-11-16 11:10 ` Andrew Burgess
2026-11-16 11:10 ` [PATCH 2/5] gdbserver: prevent buffer overrun for QTDPsrc packet Andrew Burgess
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Andrew Burgess @ 2026-11-16 11:10 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
In the following commits I plan to make some changes in, and fix some
bugs in various functions in gdbserver/tracepoint.cc. These functions
are all older GDB code, using older GDB coding styles. This commit is
a refactor to address some of these older issues. Things changed:
1. Move variable declarations inline within the function rather than
having them all at the top of the function.
2. Don't treat pointers as booleans.
3. Convert some ints to bool where this requires only minimal
changes.
4. Add missing function headers.
5. Rename tppacket to defining_tracepoint in cmd_qtdp, as the new
name is more descriptive.
6. Rename saved to start_of_type in cmd_qtdpsrc for the same reason.
7. Rename saved to start_of_text in cmd_qtnotes for the same reason.
8. Convert NULL to nullptr.
9. Change 'char *' to 'const char *' where possible.
I am only cleaning up functions that I plan to touch later in this
series.
There should be no user visible changes after this commit.
---
gdbserver/tracepoint.cc | 222 +++++++++++++++++++---------------------
1 file changed, 104 insertions(+), 118 deletions(-)
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 6f657257ee8..e7c1f0c9e7f 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -2234,10 +2234,9 @@ static void
cmd_qtinit (char *packet)
{
client_state &cs = get_client_state ();
- struct trace_state_variable *tsv, *prev, *next;
/* Can't do this command without a pid attached. */
- if (current_thread == NULL)
+ if (current_thread == nullptr)
{
write_enn (packet);
return;
@@ -2253,19 +2252,19 @@ cmd_qtinit (char *packet)
clear_installed_tracepoints ();
clear_readonly_regions ();
- tracepoints = NULL;
+ tracepoints = nullptr;
/* Clear out any leftover trace state variables. Ones with target
defined getters should be kept however. */
- prev = NULL;
- tsv = trace_state_variables;
- while (tsv)
+ struct trace_state_variable *prev = nullptr;
+ struct trace_state_variable *tsv = trace_state_variables;
+ while (tsv != nullptr)
{
trace_debug ("Looking at var %d", tsv->number);
- if (tsv->getter == NULL)
+ if (tsv->getter == nullptr)
{
- next = tsv->next;
- if (prev)
+ struct trace_state_variable *next = tsv->next;
+ if (prev != nullptr)
prev->next = next;
else
trace_state_variables = next;
@@ -2293,16 +2292,16 @@ cmd_qtinit (char *packet)
static void
clear_installed_tracepoints (void)
{
- struct tracepoint *tpoint;
-
target_pause_all (true);
/* Restore any bytes overwritten by tracepoints. */
- for (tpoint = tracepoints; tpoint; tpoint = tpoint->next)
+ for (struct tracepoint *tpoint = tracepoints;
+ tpoint != nullptr;
+ tpoint = tpoint->next)
{
/* Catch the case where we might try to remove a tracepoint that
was never actually installed. */
- if (tpoint->handle == NULL)
+ if (tpoint->handle == nullptr)
{
trace_debug ("Tracepoint %d at 0x%s was "
"never installed, nothing to clear",
@@ -2330,7 +2329,7 @@ clear_installed_tracepoints (void)
break;
}
- tpoint->handle = NULL;
+ tpoint->handle = nullptr;
}
target_unpause_all (true);
@@ -2341,37 +2340,33 @@ clear_installed_tracepoints (void)
static void
cmd_qtdp (char *own_buf)
{
- int tppacket;
- /* Whether there is a trailing hyphen at the end of the QTDP packet. */
- int trail_hyphen = 0;
- ULONGEST num;
- ULONGEST addr;
- ULONGEST count;
- struct tracepoint *tpoint;
- const char *packet = own_buf;
-
- packet += strlen ("QTDP:");
+ const char *packet = own_buf + strlen ("QTDP:");
/* A hyphen at the beginning marks a packet specifying actions for a
tracepoint already supplied. */
- tppacket = 1;
+ bool defining_tracepoint = true;
if (*packet == '-')
{
- tppacket = 0;
+ defining_tracepoint = false;
++packet;
}
+
+ ULONGEST num, addr;
packet = unpack_varlen_hex (packet, &num);
++packet; /* skip a colon */
packet = unpack_varlen_hex (packet, &addr);
++packet; /* skip a colon */
/* See if we already have this tracepoint. */
- tpoint = find_tracepoint (num, addr);
+ struct tracepoint *tpoint = find_tracepoint (num, addr);
- if (tppacket)
+ /* Whether there is a trailing hyphen at the end of the QTDP packet. */
+ bool trail_hyphen = false;
+
+ if (defining_tracepoint)
{
/* Duplicate tracepoints are never allowed. */
- if (tpoint)
+ if (tpoint != nullptr)
{
trace_debug ("Tracepoint error: tracepoint %d"
" at 0x%s already exists",
@@ -2385,6 +2380,8 @@ cmd_qtdp (char *own_buf)
tpoint->enabled = (*packet == 'E');
++packet; /* skip 'E' */
++packet; /* skip a colon */
+
+ ULONGEST count;
packet = unpack_varlen_hex (packet, &count);
tpoint->step_count = count;
++packet; /* skip a colon */
@@ -2414,7 +2411,7 @@ cmd_qtdp (char *own_buf)
}
if (*packet == '-')
{
- trail_hyphen = 1;
+ trail_hyphen = true;
trace_debug ("Also has actions\n");
}
@@ -2424,7 +2421,7 @@ cmd_qtdp (char *own_buf)
tpoint->number, paddress (tpoint->address), tpoint->enabled,
tpoint->step_count, tpoint->pass_count);
}
- else if (tpoint)
+ else if (tpoint != nullptr)
add_tracepoint_action (tpoint, packet);
else
{
@@ -2440,7 +2437,7 @@ cmd_qtdp (char *own_buf)
trailing hyphen in QTDP packet. */
if (tracing && !trail_hyphen)
{
- struct tracepoint *tp = NULL;
+ struct tracepoint *tp = nullptr;
/* Pause all threads temporarily while we patch tracepoints. */
target_pause_all (false);
@@ -2456,7 +2453,7 @@ cmd_qtdp (char *own_buf)
if (tpoint->type != trap_tracepoint)
{
/* Find another fast tracepoint at the same address. */
- for (tp = tracepoints; tp; tp = tp->next)
+ for (tp = tracepoints; tp != nullptr; tp = tp->next)
{
if (tp->address == tpoint->address && tp->type == tpoint->type
&& tp->number != tpoint->number)
@@ -2464,7 +2461,7 @@ cmd_qtdp (char *own_buf)
}
/* TPOINT is installed at the same address as TP. */
- if (tp)
+ if (tp != nullptr)
{
if (tpoint->type == fast_tracepoint)
clone_fast_tracepoint (tpoint, tp);
@@ -2487,7 +2484,7 @@ cmd_qtdp (char *own_buf)
{
download_tracepoint (tpoint);
- if (tpoint->type == trap_tracepoint || tp == NULL)
+ if (tpoint->type == trap_tracepoint || tp == nullptr)
{
install_tracepoint (tpoint, own_buf);
if (!streq (own_buf, "OK"))
@@ -2504,28 +2501,22 @@ cmd_qtdp (char *own_buf)
write_ok (own_buf);
}
+/* Handle the QTDPsrc packet in OWN_BUF. */
+
static void
cmd_qtdpsrc (char *own_buf)
{
- ULONGEST num, addr, start, slen;
- struct tracepoint *tpoint;
- const char *packet = own_buf;
- const char *saved;
- char *srctype, *src;
- size_t nbytes;
- struct source_string *last, *newlast;
-
- packet += strlen ("QTDPsrc:");
+ const char *packet = own_buf + strlen ("QTDPsrc:");
+ ULONGEST num, addr;
packet = unpack_varlen_hex (packet, &num);
++packet; /* skip a colon */
packet = unpack_varlen_hex (packet, &addr);
++packet; /* skip a colon */
/* See if we already have this tracepoint. */
- tpoint = find_tracepoint (num, addr);
-
- if (!tpoint)
+ struct tracepoint *tpoint = find_tracepoint (num, addr);
+ if (tpoint == nullptr)
{
trace_debug ("Tracepoint error: tracepoint %d at 0x%s not found",
(int) num, paddress (addr));
@@ -2533,30 +2524,36 @@ cmd_qtdpsrc (char *own_buf)
return;
}
- saved = packet;
+ /* The start of the string type field within PACKET. */
+ const char *start_of_type = packet;
packet = strchr (packet, ':');
- srctype = (char *) xmalloc (packet - saved + 1);
- memcpy (srctype, saved, packet - saved);
- srctype[packet - saved] = '\0';
+ char *srctype = (char *) xmalloc (packet - start_of_type + 1);
+ memcpy (srctype, start_of_type, packet - start_of_type);
+ srctype[packet - start_of_type] = '\0';
++packet;
+
+ ULONGEST start, slen;
packet = unpack_varlen_hex (packet, &start);
++packet; /* skip a colon */
packet = unpack_varlen_hex (packet, &slen);
++packet; /* skip a colon */
- src = (char *) xmalloc (slen + 1);
- nbytes = hex2bin (packet, (gdb_byte *) src, strlen (packet) / 2);
+ char *src = (char *) xmalloc (slen + 1);
+ size_t nbytes = hex2bin (packet, (gdb_byte *) src, strlen (packet) / 2);
src[nbytes] = '\0';
- newlast = XNEW (struct source_string);
+ struct source_string *newlast = XNEW (struct source_string);
newlast->type = srctype;
newlast->str = src;
- newlast->next = NULL;
+ newlast->next = nullptr;
/* Always add a source string to the end of the list;
this keeps sequences of actions/commands in the right
order. */
- if (tpoint->source_strings)
+ if (tpoint->source_strings != nullptr)
{
- for (last = tpoint->source_strings; last->next; last = last->next)
+ struct source_string *last;
+ for (last = tpoint->source_strings;
+ last->next != nullptr;
+ last = last->next)
;
last->next = newlast;
}
@@ -2566,17 +2563,14 @@ cmd_qtdpsrc (char *own_buf)
write_ok (own_buf);
}
+/* Handle the QTDV packet in OWN_BUF. */
+
static void
cmd_qtdv (char *own_buf)
{
+ const char *packet = own_buf + strlen ("QTDV:");
+
ULONGEST num, val, builtin;
- char *varname;
- size_t nbytes;
- struct trace_state_variable *tsv;
- const char *packet = own_buf;
-
- packet += strlen ("QTDV:");
-
packet = unpack_varlen_hex (packet, &num);
++packet; /* skip a colon */
packet = unpack_varlen_hex (packet, &val);
@@ -2584,12 +2578,12 @@ cmd_qtdv (char *own_buf)
packet = unpack_varlen_hex (packet, &builtin);
++packet; /* skip a colon */
- nbytes = strlen (packet) / 2;
- varname = (char *) xmalloc (nbytes + 1);
+ size_t nbytes = strlen (packet) / 2;
+ char *varname = (char *) xmalloc (nbytes + 1);
nbytes = hex2bin (packet, (gdb_byte *) varname, nbytes);
varname[nbytes] = '\0';
- tsv = create_trace_state_variable (num, 1);
+ struct trace_state_variable *tsv = create_trace_state_variable (num, 1);
tsv->initial_value = (LONGEST) val;
tsv->name = varname;
@@ -2598,21 +2592,22 @@ cmd_qtdv (char *own_buf)
write_ok (own_buf);
}
-static void
-cmd_qtenable_disable (char *own_buf, int enable)
-{
- const char *packet = own_buf;
- ULONGEST num, addr;
- struct tracepoint *tp;
+/* Handle a QTEnable or QTDisable packet in OWN_BUF. When ENABLE is
+ true it's a QTEnable packet, otherwise it's a QTDisable packet. */
- packet += strlen (enable ? "QTEnable:" : "QTDisable:");
+static void
+cmd_qtenable_disable (char *own_buf, bool enable)
+{
+ const char *packet = own_buf + strlen (enable ? "QTEnable:" : "QTDisable:");
+
+ ULONGEST num, addr;
packet = unpack_varlen_hex (packet, &num);
++packet; /* skip a colon */
packet = unpack_varlen_hex (packet, &addr);
- tp = find_tracepoint (num, addr);
+ struct tracepoint *tp = find_tracepoint (num, addr);
- if (tp)
+ if (tp != nullptr)
{
if ((enable && tp->enabled) || (!enable && !tp->enabled))
{
@@ -2635,7 +2630,7 @@ cmd_qtenable_disable (char *own_buf, int enable)
CORE_ADDR obj_addr = tp->obj_addr_on_target + offset;
int ret = write_inferior_int8 (obj_addr, enable);
- if (ret)
+ if (ret != 0)
{
trace_debug ("Cannot write enabled flag into "
"inferior process memory");
@@ -2711,24 +2706,22 @@ clear_readonly_regions (void)
static void
cmd_qtro (char *own_buf)
{
- ULONGEST start, end;
- struct readonly_region *roreg;
- const char *packet = own_buf;
-
trace_debug ("Want to mark readonly regions");
clear_readonly_regions ();
- packet += strlen ("QTro");
+ const char *packet = own_buf + strlen ("QTro");
while (*packet == ':')
{
++packet; /* skip a colon */
+
+ ULONGEST start, end;
packet = unpack_varlen_hex (packet, &start);
++packet; /* skip a comma */
packet = unpack_varlen_hex (packet, &end);
- roreg = XNEW (struct readonly_region);
+ struct readonly_region *roreg = XNEW (struct readonly_region);
roreg->start = start;
roreg->end = end;
roreg->next = readonly_regions;
@@ -3458,23 +3451,21 @@ cmd_qtstatus (char *packet)
buf1, buf2);
}
+/* Handle the qTP packet in OWN_BUF. */
+
static void
cmd_qtp (char *own_buf)
{
+ const char *packet = own_buf + strlen ("qTP:");
+
ULONGEST num, addr;
- struct tracepoint *tpoint;
- const char *packet = own_buf;
-
- packet += strlen ("qTP:");
-
packet = unpack_varlen_hex (packet, &num);
++packet; /* skip a colon */
packet = unpack_varlen_hex (packet, &addr);
/* See if we already have this tracepoint. */
- tpoint = find_tracepoint (num, addr);
-
- if (!tpoint)
+ struct tracepoint *tpoint = find_tracepoint (num, addr);
+ if (tpoint == nullptr)
{
trace_debug ("Tracepoint error: tracepoint %d at 0x%s not found",
(int) num, paddress (addr));
@@ -3718,12 +3709,9 @@ cmd_qtminftpilen (char *packet)
static void
cmd_qtbuffer (char *own_buf)
{
- ULONGEST offset, num, tot;
- unsigned char *tbp;
- const char *packet = own_buf;
-
- packet += strlen ("qTBuffer:");
+ const char *packet = own_buf + strlen ("qTBuffer:");
+ ULONGEST offset, num;
packet = unpack_varlen_hex (packet, &offset);
++packet; /* skip a comma */
unpack_varlen_hex (packet, &num);
@@ -3731,7 +3719,7 @@ cmd_qtbuffer (char *own_buf)
trace_debug ("Want to get trace buffer, %d bytes at offset 0x%s",
(int) num, phex_nz (offset, 0));
- tot = (trace_buffer_hi - trace_buffer_lo) - free_space ();
+ ULONGEST tot = (trace_buffer_hi - trace_buffer_lo) - free_space ();
/* If we're right at the end, reply specially that we're done. */
if (offset == tot)
@@ -3749,7 +3737,7 @@ cmd_qtbuffer (char *own_buf)
/* Compute the pointer corresponding to the given offset, accounting
for wraparound. */
- tbp = trace_buffer_start + offset;
+ unsigned char *tbp = trace_buffer_start + offset;
if (tbp >= trace_buffer_wrap)
tbp -= (trace_buffer_wrap - trace_buffer_lo);
@@ -3810,25 +3798,23 @@ cmd_bigqtbuffer_size (char *own_buf)
write_ok (own_buf);
}
+/* Handle the QTNotes packet in OWN_BUF. */
+
static void
cmd_qtnotes (char *own_buf)
{
- size_t nbytes;
- char *saved, *user, *notes, *stopnote;
- char *packet = own_buf;
+ const char *packet = own_buf + strlen ("QTNotes:");
- packet += strlen ("QTNotes:");
-
- while (*packet)
+ while (*packet != '\0')
{
if (startswith (packet, "user:"))
{
packet += strlen ("user:");
- saved = packet;
+ const char *start_of_text = packet;
packet = strchr (packet, ';');
- nbytes = (packet - saved) / 2;
- user = (char *) xmalloc (nbytes + 1);
- nbytes = hex2bin (saved, (gdb_byte *) user, nbytes);
+ size_t nbytes = (packet - start_of_text) / 2;
+ char *user = (char *) xmalloc (nbytes + 1);
+ nbytes = hex2bin (start_of_text, (gdb_byte *) user, nbytes);
user[nbytes] = '\0';
++packet; /* skip the semicolon */
trace_debug ("User is '%s'", user);
@@ -3838,11 +3824,11 @@ cmd_qtnotes (char *own_buf)
else if (startswith (packet, "notes:"))
{
packet += strlen ("notes:");
- saved = packet;
+ const char *start_of_text = packet;
packet = strchr (packet, ';');
- nbytes = (packet - saved) / 2;
- notes = (char *) xmalloc (nbytes + 1);
- nbytes = hex2bin (saved, (gdb_byte *) notes, nbytes);
+ size_t nbytes = (packet - start_of_text) / 2;
+ char *notes = (char *) xmalloc (nbytes + 1);
+ nbytes = hex2bin (start_of_text, (gdb_byte *) notes, nbytes);
notes[nbytes] = '\0';
++packet; /* skip the semicolon */
trace_debug ("Notes is '%s'", notes);
@@ -3852,11 +3838,11 @@ cmd_qtnotes (char *own_buf)
else if (startswith (packet, "tstop:"))
{
packet += strlen ("tstop:");
- saved = packet;
+ const char *start_of_text = packet;
packet = strchr (packet, ';');
- nbytes = (packet - saved) / 2;
- stopnote = (char *) xmalloc (nbytes + 1);
- nbytes = hex2bin (saved, (gdb_byte *) stopnote, nbytes);
+ size_t nbytes = (packet - start_of_text) / 2;
+ char *stopnote = (char *) xmalloc (nbytes + 1);
+ nbytes = hex2bin (start_of_text, (gdb_byte *) stopnote, nbytes);
stopnote[nbytes] = '\0';
++packet; /* skip the semicolon */
trace_debug ("tstop note is '%s'", stopnote);
@@ -3890,12 +3876,12 @@ handle_tracepoint_general_set (char *packet)
}
else if (startswith (packet, "QTEnable:"))
{
- cmd_qtenable_disable (packet, 1);
+ cmd_qtenable_disable (packet, true);
return 1;
}
else if (startswith (packet, "QTDisable:"))
{
- cmd_qtenable_disable (packet, 0);
+ cmd_qtenable_disable (packet, false);
return 1;
}
else if (startswith (packet, "QTDV:"))
--
2.25.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/5] gdbserver: prevent buffer overrun for QTDPsrc packet
2026-11-16 11:10 [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet Andrew Burgess
2026-11-16 11:10 ` [PATCH 1/5] gdbserver: clean up some older code in tracepoint.cc Andrew Burgess
@ 2026-11-16 11:10 ` Andrew Burgess
2026-11-19 19:51 ` Keith Seitz
2026-11-16 11:10 ` [PATCH 3/5] gdbserver: improve packet parsing in tracepoint.cc Andrew Burgess
` (3 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Andrew Burgess @ 2026-11-16 11:10 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
The QTDPsrc packet format is:
QTDPsrc:N:ADDR:TYPE:START:SLEN:BYTES
The BYTES is a hex encoded string. The START and SLEN allow for
strings that are longer than a single packet, START is the position of
BYTES within the full string, and SLEN is the length of the full
string.
Critically, the hex decoding of BYTES might not equal SLEN.
The current handling of QTDPsrc makes two errors: it allocates a
buffer based on SLEN. A malicious incoming packet could include an
arbitrarily large SLEN value causing gdbserver to allocate a huge
amount of memory. This would either cause the gdbserver process to
terminate with an out of memory error, or might bring down the machine
due to memory pressure.
The second problem is that gdbserver converts bytes from the packet
into the allocated buffer using a call to hex2bin, and uses the packet
length as the limit on the number of bytes translated. This means
that if SLEN is less than the length of the hex decoded string,
gdbserver will overflow the allocated buffer and write to arbitrary
memory.
This commit makes the following changes:
1. Ensure that SLEN matches the length of the hex decoded BYTES
string.
I did consider just ignoring SLEN, but that means gdbserver would
accept invalid packets, e.g. SLEN less than the length of the hex
decoded BYTES string. And that seemed like a bad idea.
2. Allocate the buffer, and cap the hex2bin call based on the length
of the hex decoded BYTES string, not SLEN. This means that if
the rules for SLEN change in the future the buffer will be the
right size to decode BYTES.
One point of interest is that I added a call `xfree (srctype)` on the
error path. This avoids leaking a previously allocated buffer. This
is temporary, a later commit in this series switches the buffer to use
gdb::unique_xmalloc_ptr<char> instead and the xfree will be removed.
Adding the xfree now just means this commit can be more focussed.
The header comment in the new test script, and the name of the script
itself, both indicate that this script is for testing more than the
QTDPsrc packet. Right now this is not the case, but later commits in
this series will add more tests. I've left the header comment as
generic text that talks about testing multiple tracepoint packets to
avoid churn in the next commit.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34968
---
.../gdb.server/invalid-tracepoint-packets.exp | 141 ++++++++++++++++++
gdbserver/tracepoint.cc | 29 +++-
2 files changed, 168 insertions(+), 2 deletions(-)
create mode 100644 gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
diff --git a/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
new file mode 100644
index 00000000000..d82647cbe63
--- /dev/null
+++ b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
@@ -0,0 +1,141 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2026 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test some tracepoint related packets, focusing mostly on error
+# handling within gdbserver. This does not test every tracepoint
+# related packet. This test was written while fixing some bugs in
+# various packets and the tests were only added for packets being
+# fixed.
+#
+# Start gdbserver and connect. Use 'maint packet ...' to send
+# tracepoint related packets to gdbserver. Some of these packets are
+# valid, others are invalid.
+#
+# This manual packet sending is used in order to be able to send the
+# invalid packets.
+
+load_lib gdbserver-support.exp
+
+require allow_gdbserver_tests
+
+standard_testfile normal.c
+
+if {[build_executable "failed to build" $testfile $srcfile]} {
+ return
+}
+
+# Some global regexp used in the tests below.
+set error_re "\r\nreceived: \"E01\""
+set ok_re "\r\nreceived: \"OK\""
+
+# Start GDB and gdbserver ready for the test. Return false if
+# anything goes wrong, otherwise, return true.
+proc start_gdbserver_for_test {} {
+ clean_restart $::testfile
+
+ # Make sure we're disconnected, in case we're testing with an
+ # extended-remote board, therefore already connected.
+ gdb_test "disconnect" ".*"
+
+ # Start gdbserver and connect.
+ set res [gdbserver_spawn ""]
+ set gdbserver_protocol [lindex $res 0]
+ set gdbserver_gdbport [lindex $res 1]
+ set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
+ if {![gdb_assert {$res == 0} "connect"]} {
+ return false
+ }
+
+ return true
+}
+
+# Test the QTDPsrc packet.
+proc_with_prefix test_qtdpsrc {} {
+ if {![start_gdbserver_for_test]} {
+ return
+ }
+
+ # Disassemble main and find an address at which we could place a
+ # tracepoint.
+ set addresses {}
+ gdb_test_multiple "disassemble main" "" -lbl {
+ -re "\r\n\\s+0x0*(\[0-9a-f\]+)\\s+\[^\r\n\]+(?=\r\n)" {
+ set addr $expect_out(1,string)
+ lappend addresses $addr
+ exp_continue
+ }
+
+ -re "^\r\n$::gdb_prompt $" {
+ gdb_assert {[llength $addresses] > 0} \
+ "found instruction addresses"
+ }
+ }
+
+ # We need at least one address in main for this test.
+ if {[llength $addresses] < 1} {
+ unsupported "not enough instruction addresses in main"
+ gdbserver_exit false
+ return
+ }
+
+ # Record the address we'll use in this test.
+ set addr [lindex $addresses 0]
+
+ # Create a tracepoint at ADDR. Do this manually as the rest of this
+ # test also does manual packet manipulation.
+ gdb_test_multiple "maint packet QTDP:1:$addr:D:1:1" "create tracepoint" {
+ -re -wrap "\r\nreceived: \"OK\"" {
+ pass $gdb_test_name
+ }
+
+ -re -wrap "" {
+ unsupported $gdb_test_name
+ gdbserver_exit false
+ return
+ }
+ }
+
+ # Now send invalid QTDPsrc packets at gdbserver and check they are all
+ # rejected.
+ set prefix "QTDPsrc:1:$addr:cond:0"
+
+ # Undersized strings. The packet declares that it has a string
+ # containing 2 bytes, but COUNT is the actual number of nibbles
+ # supplied.
+ foreach count {0 1 2 3} {
+ gdb_test "maint packet ${prefix}:2:[string repeat 1 $count]" \
+ $::error_re "string of $count nibbles and declared length 2 bytes"
+ }
+
+ # Packets with oversized strings of various sizes. The packet
+ # declares that it has a string containing 1 byte, but COUNT is the
+ # actual number of nibbles supplied.
+ foreach count {3 100 500 1000 2000 4000} {
+ gdb_test "maint packet ${prefix}:1:[string repeat 1 $count]" \
+ $::error_re "string of $count nibbles and declared length 1 byte"
+ }
+
+ # Test some valid packets.
+ gdb_test "maint packet ${prefix}:1:41" $::ok_re "valid string accepted"
+ gdb_test "maint packet ${prefix}:3:414243" $::ok_re \
+ "valid multi-byte string accepted"
+ gdb_test "maint packet ${prefix}:0:" $::ok_re "empty string accepted"
+
+ gdbserver_exit false
+}
+
+test_qtdpsrc
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index e7c1f0c9e7f..00cbec8c8da 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -2532,15 +2532,40 @@ cmd_qtdpsrc (char *own_buf)
srctype[packet - start_of_type] = '\0';
++packet;
+ /* The QTDPsrc spec says that SLEN can be longer than the delivered string
+ in order to support strings longer than can fit in a single packet.
+ The START indicates where the string from this packet fits into the
+ overall string.
+
+ However, gdbserver has never (yet) supported strings larger than a
+ single packet, which is why the START field here is ignored, and why we
+ check SLEN against the remaining packet length. */
ULONGEST start, slen;
packet = unpack_varlen_hex (packet, &start);
++packet; /* skip a colon */
packet = unpack_varlen_hex (packet, &slen);
++packet; /* skip a colon */
- char *src = (char *) xmalloc (slen + 1);
- size_t nbytes = hex2bin (packet, (gdb_byte *) src, strlen (packet) / 2);
+
+ size_t len = strlen (packet);
+ if (slen != len / 2 || len % 2 != 0)
+ {
+ trace_debug ("Tracepoint error: invalid string length %s in: %s",
+ pulongest (slen), own_buf);
+ write_enn (own_buf);
+ xfree (srctype);
+ return;
+ }
+
+ char *src = (char *) xmalloc (len / 2 + 1);
+ size_t nbytes = hex2bin (packet, (gdb_byte *) src,
+ static_cast<int> (len / 2));
src[nbytes] = '\0';
+ /* Because we check SLEN against the packet length above, either the packet
+ is fully parsed, or hex2bin will have thrown an error on seeing a
+ non-hex character. */
+ gdb_assert (packet[nbytes * 2] == '\0');
+
struct source_string *newlast = XNEW (struct source_string);
newlast->type = srctype;
newlast->str = src;
--
2.25.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/5] gdbserver: improve packet parsing in tracepoint.cc
2026-11-16 11:10 [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet Andrew Burgess
2026-11-16 11:10 ` [PATCH 1/5] gdbserver: clean up some older code in tracepoint.cc Andrew Burgess
2026-11-16 11:10 ` [PATCH 2/5] gdbserver: prevent buffer overrun for QTDPsrc packet Andrew Burgess
@ 2026-11-16 11:10 ` Andrew Burgess
2026-11-16 11:10 ` [PATCH 4/5] gdbserver: don't leak trace variable names if reusing variable numbers Andrew Burgess
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Andrew Burgess @ 2026-11-16 11:10 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
The current packet parsing code in gdbserver/tracepoint.cc has code
like this:
++packet; /* skip a colon */
Where PACKET points into the incoming packet buffer. There is no
validation that *PACKET actually points at a colon character. This
means that incorrectly formatted incoming packets might be accepted
with unexpected results. For example, *PACKET might be the end of
packet null character, in which case gdbserver will skip the null and
start processing garbage bytes as packet data.
This commit introduces check_char_and_skip_or_write_error which wraps
a common pattern; check if *PACKET is a specific character, and if it
is, move PACKET past that character. If *PACKET is not the expected
character then write an error into the outgoing packet buffer and
return.
I then make use of this function throughout tracepoint.cc to improve
the packet parsing.
There are two other, similar fixes included in this commit. In
cmd_qtdp we need to check for either 'E' or 'D'; as
check_char_and_skip_or_write_error only checks for one named
character, I wrote that check inline.
And in cmd_qtdpsrc and cmd_qtnotes we use strchr to search for the
next ':' or ';' character. However, if the character is missing then
we will get back nullptr. Currently the code doesn't check for this
and just continues. In these cases I've introduced a nullptr check
and early return.
Additionally in cmd_qtdpsrc, at the new early return sites, I've added
an xfree call to release a buffer that is allocated earlier in the
function with xmalloc. This buffer would be better managed using
gdb::unique_xmalloc_ptr. I have left switching to
gdb::unique_xmalloc_ptr until a later commit in order to keep this
commit more focused. So for now we gain some xfree calls, but these
will be removed by the end of this series.
There are new tests covering the new checks.
---
.../gdb.server/invalid-tracepoint-packets.exp | 295 +++++++++++++++++-
gdbserver/tracepoint.cc | 125 +++++++-
2 files changed, 395 insertions(+), 25 deletions(-)
diff --git a/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
index d82647cbe63..de37d657b57 100644
--- a/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
+++ b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
@@ -63,12 +63,10 @@ proc start_gdbserver_for_test {} {
return true
}
-# Test the QTDPsrc packet.
-proc_with_prefix test_qtdpsrc {} {
- if {![start_gdbserver_for_test]} {
- return
- }
-
+# Disassemble the main function and return a list containing the addresses
+# of each instruction. The returned addresses have the leading 0x and any
+# leading 0s stripped off.
+proc disassemble_main_for_addresses {} {
# Disassemble main and find an address at which we could place a
# tracepoint.
set addresses {}
@@ -85,8 +83,74 @@ proc_with_prefix test_qtdpsrc {} {
}
}
- # We need at least one address in main for this test.
- if {[llength $addresses] < 1} {
+ return $addresses
+}
+
+# Having sent gdbserver a tracepoint related packet that contains a
+# non-hex character in a place where only hex characters are allowed,
+# we currently expect to see gdbserver exit after printing an error
+# about invalid hex digits. Check for the error message and check
+# gdbserver exits.
+#
+# Before returning, clean up the gdbserver state now that it is no
+# longer running.
+proc ensure_gdbserver_exited_due_to_non_hex {} {
+ # Check the gdbserver exited as we expect.
+ with_spawn_id $::server_spawn_id {
+ set saw_invalid_hex_msg false
+ gdb_test_multiple "" "gdbserver exited" -lbl {
+ -re "\r\ngdbserver: Invalid hex digit \[^\r\n\]+(?=\r\n)" {
+ set saw_invalid_hex_msg true
+ exp_continue
+ }
+ eof {
+ gdb_assert { $saw_invalid_hex_msg } $gdb_test_name
+ }
+ timeout {
+ fail $gdb_test_name
+ }
+ }
+ }
+
+ # Clean up gdbserver state.
+ close_gdbserver
+}
+
+# Test the QTDV packet.
+proc_with_prefix test_qtdv {} {
+ if {![start_gdbserver_for_test]} {
+ return
+ }
+
+ # Tests with missing fields of the packet.
+ gdb_test "maint packet QTDV:2" \
+ $::error_re "missing colon after number"
+
+ gdb_test "maint packet QTDV:2:5" \
+ $::error_re "missing colon after value"
+
+ gdb_test "maint packet QTDV:2:5:0" \
+ $::error_re "missing colon after builtin flag"
+
+ # Send a valid QTDV packet to ensure valid packets are accepted.
+ gdb_test "maint packet QTDV:2:7:0:616263" $::ok_re \
+ "valid QTDV packet is accepted"
+
+ gdbserver_exit false
+}
+
+# Test the QTDPsrc packet.
+proc_with_prefix test_qtdpsrc {} {
+ if {![start_gdbserver_for_test]} {
+ return
+ }
+
+ # Disassemble main and find an address at which we could place a
+ # tracepoint.
+ set addresses [disassemble_main_for_addresses]
+
+ # We need at least 2 different addresses in main for this test.
+ if {[llength $addresses] < 2} {
unsupported "not enough instruction addresses in main"
gdbserver_exit false
return
@@ -94,6 +158,7 @@ proc_with_prefix test_qtdpsrc {} {
# Record the address we'll use in this test.
set addr [lindex $addresses 0]
+ set other_addr [lindex $addresses 1]
# Create a tracepoint at ADDR. Do this manually as the rest of this
# test also does manual packet manipulation.
@@ -129,13 +194,227 @@ proc_with_prefix test_qtdpsrc {} {
$::error_re "string of $count nibbles and declared length 1 byte"
}
+ # Tests with missing fields of the packet.
+ gdb_test "maint packet QTDPsrc:1234" \
+ $::error_re "missing colon after number"
+
+ gdb_test "maint packet QTDPsrc:1:$addr" \
+ $::error_re "missing colon after address"
+
+ gdb_test "maint packet QTDPsrc:1:$addr:cond" \
+ $::error_re "missing colon after type"
+
+ gdb_test "maint packet QTDPsrc:1:$addr:cond:0" \
+ $::error_re "missing colon after start"
+
+ gdb_test "maint packet QTDPsrc:1:$addr:cond:0:1" \
+ $::error_re "missing colon after length"
+
+ # Test with an invalid tracepoint number.
+ gdb_test "maint packet QTDPsrc:2:$addr:cond:0:1:41" \
+ $::error_re "invalid tracepoint number"
+
+ # Test with a valid tracepoint number, but the wrong address.
+ gdb_test "maint packet QTDPsrc:1:$other_addr:cond:0:1:41" \
+ $::error_re "invalid tracepoint address"
+
# Test some valid packets.
gdb_test "maint packet ${prefix}:1:41" $::ok_re "valid string accepted"
gdb_test "maint packet ${prefix}:3:414243" $::ok_re \
"valid multi-byte string accepted"
gdb_test "maint packet ${prefix}:0:" $::ok_re "empty string accepted"
+ # Test a packet containing a string encoding with non-hex characters.
+ # Currently this will cause gdbserver to exit as we start with --once.
+ # This behaviour could probably be changed in the future as exiting
+ # gdbserver is a pretty extreme reaction to bad packet data. But for
+ # now this test ensures that the packet is handled as we expect.
+ gdb_test "maint packet ${prefix}:1:zz" \
+ $::error_re "string encoding is non-hex"
+
+ ensure_gdbserver_exited_due_to_non_hex
+}
+
+# Test QTDP packet.
+proc_with_prefix test_qtdp {} {
+ if {![start_gdbserver_for_test]} {
+ return
+ }
+
+ set addresses [disassemble_main_for_addresses]
+ if {[llength $addresses] < 1} {
+ unsupported "not enough instruction addresses in main"
+ gdbserver_exit false
+ return
+ }
+
+ set addr [lindex $addresses 0]
+
+ # Send a valid packet to ensure valid packets are accepted.
+ gdb_test "maint packet QTDP:1:$addr:D:1:1" $::ok_re "create tracepoint"
+
+ # Send packets with missing fields.
+ gdb_test "maint packet QTDP:1" $::error_re "missing colon after number"
+ gdb_test "maint packet QTDP:1:$addr" $::error_re \
+ "missing colon after address"
+ gdb_test "maint packet QTDP:1:$addr:D" $::error_re \
+ "missing colon after enable/disable field"
+ gdb_test "maint packet QTDP:1:$addr:D:1" $::error_re \
+ "missing colon after step count"
+
+ # Packets with invalid enable/disable field.
+ gdb_test "maint packet QTDP:1:$addr:X:1:1" $::error_re \
+ "invalid enable/disable field"
+
gdbserver_exit false
}
+# Test QTEnable and QTDisable packets.
+proc_with_prefix test_qtenable_qtdisable {} {
+ if {![start_gdbserver_for_test]} {
+ return
+ }
+
+ set addresses [disassemble_main_for_addresses]
+ if {[llength $addresses] < 1} {
+ unsupported "not enough instruction addresses in main"
+ gdbserver_exit false
+ return
+ }
+ set addr [lindex $addresses 0]
+
+ # Create a tracepoint.
+ gdb_test "maint packet QTDP:2:$addr:D:1:1" $::ok_re "create tracepoint"
+
+ # Send enable/disable packets with fields missing.
+ gdb_test "maint packet QTEnable:2" $::error_re \
+ "missing colon after number for enable"
+ gdb_test "maint packet QTDisable:2" $::error_re \
+ "missing colon after number for disable"
+
+ # Send a valid packet to ensure these work.
+ gdb_test "maint packet QTEnable:2:$addr" $::ok_re \
+ "enable tracepoint"
+ gdb_test "maint packet QTDisable:2:$addr" $::ok_re \
+ "disable tracepoint"
+
+ gdbserver_exit false
+}
+
+# Test QTro packet.
+proc_with_prefix test_qtro {} {
+ if {![start_gdbserver_for_test]} {
+ return
+ }
+
+ set addresses [disassemble_main_for_addresses]
+ if {[llength $addresses] < 2} {
+ unsupported "not enough instruction addresses in main"
+ gdbserver_exit false
+ return
+ }
+
+ set start [lindex $addresses 0]
+ set end [lindex $addresses 1]
+
+ # Send packets with missing fields.
+ gdb_test "maint packet QTro:$start" $::error_re \
+ "missing comma after start"
+ gdb_test "maint packet QTro:$start,$end:$start" $::error_re \
+ "missing comma after second start"
+
+ # Send a valid packet to ensure valid packets are accepted.
+ gdb_test "maint packet QTro:$start,$end" $::ok_re \
+ "valid packet, single range"
+ gdb_test "maint packet QTro:$start,$end:$start,$end" $::ok_re \
+ "valid packet, two ranges"
+
+ gdbserver_exit false
+}
+
+# Test qTP packet.
+proc_with_prefix test_qtp {} {
+ if {![start_gdbserver_for_test]} {
+ return
+ }
+
+ set addresses [disassemble_main_for_addresses]
+ if {[llength $addresses] < 1} {
+ unsupported "not enough instruction addresses in main"
+ gdbserver_exit false
+ return
+ }
+ set addr [lindex $addresses 0]
+
+ # Create a tracepoint.
+ gdb_test "maint packet QTDP:2:$addr:D:1:1" $::ok_re "create tracepoint"
+
+ # Send qTP packet with fields missing.
+ gdb_test "maint packet qTP:2" $::error_re "missing colon after number"
+
+ # Send a valid packet to check this can work.
+ gdb_test "maint packet qTP:2:$addr" \
+ "\r\nreceived: \"V${::decimal}:${::decimal}\"" \
+ "valid packet"
+
+ gdbserver_exit false
+}
+
+# Test QTBuffer packet.
+proc_with_prefix test_qtbuffer {} {
+ if {![start_gdbserver_for_test]} {
+ return
+ }
+
+ # Send qTBuffer packets with missing fields.
+ gdb_test "maint packet qTBuffer:2" $::error_re \
+ "missing comma after offset"
+
+ # Send a valid qTBuffer packet. Request content at offset 0. As
+ # we have not collected any trace data by this point we should get
+ # back an 'l' indicating that we are at the end of the trace buffer.
+ gdb_test "maint packet qTBuffer:0,10" \
+ "\r\nreceived: \"l\"" \
+ "valid qTBuffer"
+
+ gdbserver_exit false
+}
+
+# Test the QTNotes packet.
+proc_with_prefix test_qtnotes {} {
+ if {![start_gdbserver_for_test]} {
+ return
+ }
+
+ # Test the valid QTNotes packet case.
+ gdb_test "maint packet QTNotes:user:414243;notes:444546;tstop:47;" \
+ $::ok_re "valid QTNotes packet accepted"
+
+ # A second packet replaces the existing notes.
+ gdb_test "maint packet QTNotes:user:484950;notes:515253;tstop:54;" \
+ $::ok_re "second valid QTNotes packet accepted"
+
+ # Packets with missing field separators.
+ gdb_test "maint packet QTNotes:user:4142" $::error_re \
+ "missing semicolon after user field"
+ gdb_test "maint packet QTNotes:notes:4243" $::error_re \
+ "missing semicolon after notes field"
+ gdb_test "maint packet QTNotes:tstop:44" $::error_re \
+ "missing semicolon after tstop field"
+
+ # The invalid packets should not have updated the stored data.
+ gdb_test "maint packet qTStatus"\
+ "received: \"\[^\r\n\]*username:484950;notes:515253\[^\r\n\]*\"" \
+ "check notes with qTStatus packet"
+
+ gdbserver_exit false
+}
+
+test_qtdv
test_qtdpsrc
+test_qtdp
+test_qtenable_qtdisable
+test_qtro
+test_qtp
+test_qtbuffer
+test_qtnotes
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 00cbec8c8da..7f0b233fa43 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -2335,6 +2335,29 @@ clear_installed_tracepoints (void)
target_unpause_all (true);
}
+/* OWN_BUF is the complete packet buffer. *PTR is a pointer to a character
+ within the buffer. Check that **PTR points at character CH. If it does
+ then increment *PTR to skip the character and return true.
+
+ Otherwise, if **PTR is not character CH, write an error into OWN_BUF and
+ return false. */
+
+static bool
+check_char_and_skip_or_write_error (char *own_buf, const char **ptr, char ch)
+{
+ if (**ptr != ch)
+ {
+ trace_debug ("Tracepoint error: missing '%c' at offset %s in: %s",
+ ch, pulongest (*ptr - own_buf), own_buf);
+ write_enn (own_buf);
+ return false;
+ }
+
+ /* Skip the CH character. */
+ (*ptr)++;
+ return true;
+}
+
/* Parse a packet that defines a tracepoint. */
static void
@@ -2353,9 +2376,11 @@ cmd_qtdp (char *own_buf)
ULONGEST num, addr;
packet = unpack_varlen_hex (packet, &num);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ return;
packet = unpack_varlen_hex (packet, &addr);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ return;
/* See if we already have this tracepoint. */
struct tracepoint *tpoint = find_tracepoint (num, addr);
@@ -2377,14 +2402,34 @@ cmd_qtdp (char *own_buf)
tpoint = add_tracepoint (num, addr);
+ /* Check the ENA field is either 'E' or 'D'. */
+ if (*packet != 'E' && *packet != 'D')
+ {
+ trace_debug ("Tracepoint error: missing 'E' or 'D' at offset %s in: %s",
+ pulongest (packet - own_buf), own_buf);
+ write_enn (own_buf);
+ remove_tracepoint (tpoint);
+ return;
+ }
+
tpoint->enabled = (*packet == 'E');
- ++packet; /* skip 'E' */
- ++packet; /* skip a colon */
+ /* Skip the 'E' or 'D'. */
+ ++packet;
+
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ {
+ remove_tracepoint (tpoint);
+ return;
+ }
ULONGEST count;
packet = unpack_varlen_hex (packet, &count);
tpoint->step_count = count;
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ {
+ remove_tracepoint (tpoint);
+ return;
+ }
packet = unpack_varlen_hex (packet, &count);
tpoint->pass_count = count;
/* See if we have any of the additional optional fields. */
@@ -2510,9 +2555,11 @@ cmd_qtdpsrc (char *own_buf)
ULONGEST num, addr;
packet = unpack_varlen_hex (packet, &num);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ return;
packet = unpack_varlen_hex (packet, &addr);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ return;
/* See if we already have this tracepoint. */
struct tracepoint *tpoint = find_tracepoint (num, addr);
@@ -2527,6 +2574,12 @@ cmd_qtdpsrc (char *own_buf)
/* The start of the string type field within PACKET. */
const char *start_of_type = packet;
packet = strchr (packet, ':');
+ if (packet == nullptr)
+ {
+ trace_debug ("Tracepoint error: missing ':' in: %s", own_buf);
+ write_enn (own_buf);
+ return;
+ }
char *srctype = (char *) xmalloc (packet - start_of_type + 1);
memcpy (srctype, start_of_type, packet - start_of_type);
srctype[packet - start_of_type] = '\0';
@@ -2542,9 +2595,17 @@ cmd_qtdpsrc (char *own_buf)
check SLEN against the remaining packet length. */
ULONGEST start, slen;
packet = unpack_varlen_hex (packet, &start);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ {
+ xfree (srctype);
+ return;
+ }
packet = unpack_varlen_hex (packet, &slen);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ {
+ xfree (srctype);
+ return;
+ }
size_t len = strlen (packet);
if (slen != len / 2 || len % 2 != 0)
@@ -2597,11 +2658,14 @@ cmd_qtdv (char *own_buf)
ULONGEST num, val, builtin;
packet = unpack_varlen_hex (packet, &num);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ return;
packet = unpack_varlen_hex (packet, &val);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ return;
packet = unpack_varlen_hex (packet, &builtin);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ return;
size_t nbytes = strlen (packet) / 2;
char *varname = (char *) xmalloc (nbytes + 1);
@@ -2627,7 +2691,8 @@ cmd_qtenable_disable (char *own_buf, bool enable)
ULONGEST num, addr;
packet = unpack_varlen_hex (packet, &num);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ return;
packet = unpack_varlen_hex (packet, &addr);
struct tracepoint *tp = find_tracepoint (num, addr);
@@ -2739,11 +2804,17 @@ cmd_qtro (char *own_buf)
while (*packet == ':')
{
- ++packet; /* skip a colon */
+ ++packet;
ULONGEST start, end;
packet = unpack_varlen_hex (packet, &start);
- ++packet; /* skip a comma */
+
+ /* The character *PACKET should be a comma. If it is not then write
+ an error into OWN_BUF and return. If there were multiple regions
+ in this packet then some might already have been set by this
+ point. The next QTro packet will clear the region list. */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ','))
+ return;
packet = unpack_varlen_hex (packet, &end);
struct readonly_region *roreg = XNEW (struct readonly_region);
@@ -3485,7 +3556,8 @@ cmd_qtp (char *own_buf)
ULONGEST num, addr;
packet = unpack_varlen_hex (packet, &num);
- ++packet; /* skip a colon */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
+ return;
packet = unpack_varlen_hex (packet, &addr);
/* See if we already have this tracepoint. */
@@ -3738,7 +3810,8 @@ cmd_qtbuffer (char *own_buf)
ULONGEST offset, num;
packet = unpack_varlen_hex (packet, &offset);
- ++packet; /* skip a comma */
+ if (!check_char_and_skip_or_write_error (own_buf, &packet, ','))
+ return;
unpack_varlen_hex (packet, &num);
trace_debug ("Want to get trace buffer, %d bytes at offset 0x%s",
@@ -3837,6 +3910,12 @@ cmd_qtnotes (char *own_buf)
packet += strlen ("user:");
const char *start_of_text = packet;
packet = strchr (packet, ';');
+ if (packet == nullptr)
+ {
+ trace_debug ("Tracepoint error: missing ';' in: %s", own_buf);
+ write_enn (own_buf);
+ return;
+ }
size_t nbytes = (packet - start_of_text) / 2;
char *user = (char *) xmalloc (nbytes + 1);
nbytes = hex2bin (start_of_text, (gdb_byte *) user, nbytes);
@@ -3851,6 +3930,12 @@ cmd_qtnotes (char *own_buf)
packet += strlen ("notes:");
const char *start_of_text = packet;
packet = strchr (packet, ';');
+ if (packet == nullptr)
+ {
+ trace_debug ("Tracepoint error: missing ';' in: %s", own_buf);
+ write_enn (own_buf);
+ return;
+ }
size_t nbytes = (packet - start_of_text) / 2;
char *notes = (char *) xmalloc (nbytes + 1);
nbytes = hex2bin (start_of_text, (gdb_byte *) notes, nbytes);
@@ -3865,6 +3950,12 @@ cmd_qtnotes (char *own_buf)
packet += strlen ("tstop:");
const char *start_of_text = packet;
packet = strchr (packet, ';');
+ if (packet == nullptr)
+ {
+ trace_debug ("Tracepoint error: missing ';' in: %s", own_buf);
+ write_enn (own_buf);
+ return;
+ }
size_t nbytes = (packet - start_of_text) / 2;
char *stopnote = (char *) xmalloc (nbytes + 1);
nbytes = hex2bin (start_of_text, (gdb_byte *) stopnote, nbytes);
--
2.25.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/5] gdbserver: don't leak trace variable names if reusing variable numbers
2026-11-16 11:10 [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet Andrew Burgess
` (2 preceding siblings ...)
2026-11-16 11:10 ` [PATCH 3/5] gdbserver: improve packet parsing in tracepoint.cc Andrew Burgess
@ 2026-11-16 11:10 ` Andrew Burgess
2026-11-16 11:10 ` [PATCH 5/5] gdbserver: use unique_xmalloc_ptr to avoid memory leaks Andrew Burgess
2026-11-19 19:52 ` [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet Keith Seitz
5 siblings, 0 replies; 10+ messages in thread
From: Andrew Burgess @ 2026-11-16 11:10 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
In the next commit I will close a memory leak relating to strings
parsed from some trace packets.
While working on this I realised that a QTDV packet, which creates
trace variables, can leak memory if a trace variable number is reused.
For example two packets:
QTDV:2:6:0:646566
QTDV:2:6:0:676869
The first creates trace variable #2 called "def" and the second
creates a trace variable #2 called "ghi". When the "ghi" variable is
created the string "def" will be leaked.
It is not clear from the documentation if a client should be able to
reuse trace variable numbers like this, but as this is the existing
behaviour, I have retained it while closing off the leak.
There is one tiny issue which adds some extra complexity. We
currently have a single built-in trace state variable
'trace_timestamp' which is created in the function
initialize_tracepoint. The name of this trace variable is not heap
allocated, and so should not be freed.
Initially I thought the solution to this problem was to just allocate
the 'trace_timestamp' string on the heap and so allow it to be freed,
but the situation is more complex.
The trace_timestamp variable sets a getter function by calling
set_trace_state_variable_getter, and this getter is not reset in
cmd_qtdv if an existing trace_state_variable is returned from
create_trace_state_variable. What this means is that if a client
creates a trace state variable and assigns it to number 1 then the
name of the variable will change from trace_timestamp, but its value,
as returned by the getter function will still act like
trace_timestamp.
To me, this feels like clients should not be reusing existing trace
state variable numbers at all, but definitely not those of built-in
variables.
Initially I changed cmd_qtdv to reject any QTDV packet that used the
number of an existing builtin; however the test gdb.trace/actions.exp
started failing. What's happening is that when GDB starts tracing
(with `tstart`), all the trace state variables, including the existing
builtins, are sent to gdbserver. By rejecting any QTDV that touched a
builtin I ended up rejecting an expected QTDV packet.
So my check became a little more specific; if a QTDV packet is for a
builtin, then the details from GDB need to exactly match the existing
builtin. The builtin flag must be set to non-zero, and the name must
be correct. Anything else indicates that GDB is trying to change a
builtin trace state variable, and that is not allowed. But sending
back the current variable details is fine.
Otherwise, if the QTDV is not overriding a known builtin, we do allow
the variable to be overridden; a client can override its own
variables. In this case we free the old name to avoid leaking.
Finally, while looking at the name management I spotted that
cmd_qtinit was also failing to free the names. So I have updated the
function to free the name.
I've added new tests, including tests that exercise both the
rejection of an attempt to replace built-in variable #1,
trace_timestamp, and the acceptance of GDB re-sending the builtin's
definition unchanged.
---
.../gdb.server/invalid-tracepoint-packets.exp | 26 ++++++++++++++
gdbserver/tracepoint.cc | 36 +++++++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
index de37d657b57..cbaddfd7e7b 100644
--- a/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
+++ b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
@@ -122,6 +122,28 @@ proc_with_prefix test_qtdv {} {
return
}
+ # Try to assign a new trace state variable to number 1. Number 1
+ # is already in use by the builtin 'trace_timestamp' variable, so
+ # this will be rejected.
+ gdb_test "maint packet QTDV:1:5:0:616263" $::error_re \
+ "QTDV packet rejected for number 1"
+
+ # However, if we echo back the builtin trace_timestamp definition,
+ # then gdbserver will accept this. The hex-encoded string here is
+ # 'trace_timestamp', the name of the builtin variable.
+ gdb_test \
+ "maint packet QTDV:1:0:1:74726163655f74696d657374616d70" \
+ $::ok_re "QTDV packet accepted for built-in definition"
+
+ # There's no pre-existing variable 2. Create a new trace state
+ # variable.
+ gdb_test "maint packet QTDV:2:6:0:646566" $::ok_re \
+ "valid QTDV packet accepted for number 2"
+
+ # Immediately replace our variable 2 with a new one.
+ gdb_test "maint packet QTDV:2:7:0:676869" $::ok_re \
+ "valid QTDV packet accepted to replace variable number 2"
+
# Tests with missing fields of the packet.
gdb_test "maint packet QTDV:2" \
$::error_re "missing colon after number"
@@ -136,6 +158,10 @@ proc_with_prefix test_qtdv {} {
gdb_test "maint packet QTDV:2:7:0:616263" $::ok_re \
"valid QTDV packet is accepted"
+ # Send a QTinit packet which frees all the trace state variables.
+ gdb_test "maint packet QTinit" $::ok_re \
+ "valid QTinit packet accepted"
+
gdbserver_exit false
}
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 7f0b233fa43..1e68b19d9d5 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -2269,6 +2269,11 @@ cmd_qtinit (char *packet)
else
trace_state_variables = next;
trace_debug ("Deleting var %d", tsv->number);
+
+ /* Trace state variables without a getter originated from the
+ debugger client; the name is heap allocated, and should be
+ freed now. */
+ free (tsv->name);
free (tsv);
tsv = next;
}
@@ -2673,6 +2678,37 @@ cmd_qtdv (char *own_buf)
varname[nbytes] = '\0';
struct trace_state_variable *tsv = create_trace_state_variable (num, 1);
+
+ /* If the getter is set then this is a builtin trace state variable, and
+ should not be overridden by the debug client. However, GDB will upload
+ the target's builtin variables at connection time, and then send them
+ back to the target when starting a trace run. Accept the debug client
+ re-declaring a builtin unchanged, but reject any attempt to change
+ it. */
+ if (tsv->getter != nullptr)
+ {
+ if (builtin != 0 && strcmp (varname, tsv->name) == 0)
+ {
+ /* The client is re-sending the definition of this builtin trace
+ state variable unchanged. There's nothing to do. */
+ write_ok (own_buf);
+ xfree (varname);
+ return;
+ }
+
+ /* The client tried to change this builtin state variable. As the
+ getter function is not being updated this will not do what the
+ client expects, so reject it. */
+ write_enn (own_buf);
+ xfree (varname);
+ return;
+ }
+
+ /* If NUM is a pre-existing variable then tsv->name will already be set.
+ Additionally, as the getter is NULL, the name is heap allocated and
+ should be freed now to avoid leaking. */
+ xfree (tsv->name);
+
tsv->initial_value = (LONGEST) val;
tsv->name = varname;
--
2.25.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 5/5] gdbserver: use unique_xmalloc_ptr to avoid memory leaks
2026-11-16 11:10 [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet Andrew Burgess
` (3 preceding siblings ...)
2026-11-16 11:10 ` [PATCH 4/5] gdbserver: don't leak trace variable names if reusing variable numbers Andrew Burgess
@ 2026-11-16 11:10 ` Andrew Burgess
2026-11-19 19:52 ` [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet Keith Seitz
5 siblings, 0 replies; 10+ messages in thread
From: Andrew Burgess @ 2026-11-16 11:10 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
In tracepoint.cc there are a few memory buffers allocated with malloc
which are live during a call to hex2bin. The hex2bin function can
throw an exception which will cause the memory buffers to leak.
Prevent this by holding the memory buffers in
gdb::unique_xmalloc_ptr<char> variables, so that they will be
deallocated if an exception is thrown. These changes are in
cmd_qtdpsrc, cmd_qtdv, and cmd_qtnotes.
Currently these buffers are placed into a data structure and managed
as a raw pointer, so I am still releasing the pointers from the
gdb::unique_xmalloc_ptr<char>. In the future it might be an
improvement to hold the pointers long term as
gdb::unique_xmalloc_ptr<char>, but I'm leaving that change to another
day.
There should be no significant user visible changes after this commit,
other than fewer memory leaks.
I've extended gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
with a non-hex test case in the test_qtdv proc, and a new
test_qtnotes proc; these exercise the invalid packet error paths.
Currently, for the tracepoint packets, the hex2bin exception is only
caught in captured_main (gdbserver/server.cc) where either gdbserver
will exit, or the connection will be reset to its default state
(depending on whether the --once flag was passed, see notes below).
This feels a little harsh for an invalid packet. We should just
return an error and ignore the packet, but I don't plan to change this
behaviour in this commit. As a result some of the new tests, those
that pass non-hex characters, expect gdbserver to exit after the
invalid packet. The memory leaks are visible when running under
valgrind or with the address sanitizers built in.
A note on how the --once flag (or lack thereof) affects the connection
when an exception is caught. I noticed during testing that if an
exception is caught in captured_main, and the --once flag was not
used, then gdbserver will return to the top of its connection loop,
which resets the connection state. However, gdbserver doesn't drop
any active connection. This leaves the connection in a weird state;
GDB is unaware that the per-connection settings have been reset, so
for things like noack_mode, GDB might think the flag is set to true,
while gdbserver has actually reset the flag to false. This is a
separate issue that I plan to address in a follow-up commit, not as
part of this series, which focuses on memory issues.
---
.../gdb.server/invalid-tracepoint-packets.exp | 11 ++-
gdbserver/tracepoint.cc | 70 ++++++++-----------
2 files changed, 40 insertions(+), 41 deletions(-)
diff --git a/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
index cbaddfd7e7b..b5f2a67b9ef 100644
--- a/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
+++ b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
@@ -162,7 +162,10 @@ proc_with_prefix test_qtdv {} {
gdb_test "maint packet QTinit" $::ok_re \
"valid QTinit packet accepted"
- gdbserver_exit false
+ # Non-hex characters in the variable string name.
+ gdb_test "maint packet QTDV:3:5:0:zz" $::error_re "QTDV name is non-hex"
+
+ ensure_gdbserver_exited_due_to_non_hex
}
# Test the QTDPsrc packet.
@@ -433,7 +436,11 @@ proc_with_prefix test_qtnotes {} {
"received: \"\[^\r\n\]*username:484950;notes:515253\[^\r\n\]*\"" \
"check notes with qTStatus packet"
- gdbserver_exit false
+ # Non-hex characters in the packet.
+ gdb_test "maint packet QTNotes:user:zz;" $::error_re \
+ "QTNotes user field is non-hex"
+
+ ensure_gdbserver_exited_due_to_non_hex
}
test_qtdv
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 1e68b19d9d5..f1f9a1d6859 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -2585,9 +2585,8 @@ cmd_qtdpsrc (char *own_buf)
write_enn (own_buf);
return;
}
- char *srctype = (char *) xmalloc (packet - start_of_type + 1);
- memcpy (srctype, start_of_type, packet - start_of_type);
- srctype[packet - start_of_type] = '\0';
+ gdb::unique_xmalloc_ptr<char> srctype
+ = make_unique_xstrndup (start_of_type, packet - start_of_type);
++packet;
/* The QTDPsrc spec says that SLEN can be longer than the delivered string
@@ -2601,16 +2600,10 @@ cmd_qtdpsrc (char *own_buf)
ULONGEST start, slen;
packet = unpack_varlen_hex (packet, &start);
if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
- {
- xfree (srctype);
- return;
- }
+ return;
packet = unpack_varlen_hex (packet, &slen);
if (!check_char_and_skip_or_write_error (own_buf, &packet, ':'))
- {
- xfree (srctype);
- return;
- }
+ return;
size_t len = strlen (packet);
if (slen != len / 2 || len % 2 != 0)
@@ -2618,14 +2611,13 @@ cmd_qtdpsrc (char *own_buf)
trace_debug ("Tracepoint error: invalid string length %s in: %s",
pulongest (slen), own_buf);
write_enn (own_buf);
- xfree (srctype);
return;
}
- char *src = (char *) xmalloc (len / 2 + 1);
- size_t nbytes = hex2bin (packet, (gdb_byte *) src,
+ gdb::unique_xmalloc_ptr<char> src ((char *) xmalloc (len / 2 + 1));
+ size_t nbytes = hex2bin (packet, (gdb_byte *) src.get (),
static_cast<int> (len / 2));
- src[nbytes] = '\0';
+ src.get ()[nbytes] = '\0';
/* Because we check SLEN against the packet length above, either the packet
is fully parsed, or hex2bin will have thrown an error on seeing a
@@ -2633,8 +2625,8 @@ cmd_qtdpsrc (char *own_buf)
gdb_assert (packet[nbytes * 2] == '\0');
struct source_string *newlast = XNEW (struct source_string);
- newlast->type = srctype;
- newlast->str = src;
+ newlast->type = srctype.release ();
+ newlast->str = src.release ();
newlast->next = nullptr;
/* Always add a source string to the end of the list;
this keeps sequences of actions/commands in the right
@@ -2673,9 +2665,9 @@ cmd_qtdv (char *own_buf)
return;
size_t nbytes = strlen (packet) / 2;
- char *varname = (char *) xmalloc (nbytes + 1);
- nbytes = hex2bin (packet, (gdb_byte *) varname, nbytes);
- varname[nbytes] = '\0';
+ gdb::unique_xmalloc_ptr<char> varname ((char *) xmalloc (nbytes + 1));
+ nbytes = hex2bin (packet, (gdb_byte *) varname.get (), nbytes);
+ varname.get ()[nbytes] = '\0';
struct trace_state_variable *tsv = create_trace_state_variable (num, 1);
@@ -2687,12 +2679,11 @@ cmd_qtdv (char *own_buf)
it. */
if (tsv->getter != nullptr)
{
- if (builtin != 0 && strcmp (varname, tsv->name) == 0)
+ if (builtin != 0 && strcmp (varname.get (), tsv->name) == 0)
{
/* The client is re-sending the definition of this builtin trace
state variable unchanged. There's nothing to do. */
write_ok (own_buf);
- xfree (varname);
return;
}
@@ -2700,7 +2691,6 @@ cmd_qtdv (char *own_buf)
getter function is not being updated this will not do what the
client expects, so reject it. */
write_enn (own_buf);
- xfree (varname);
return;
}
@@ -2710,7 +2700,7 @@ cmd_qtdv (char *own_buf)
xfree (tsv->name);
tsv->initial_value = (LONGEST) val;
- tsv->name = varname;
+ tsv->name = varname.release ();
set_trace_state_variable_value (num, (LONGEST) val);
@@ -3953,13 +3943,13 @@ cmd_qtnotes (char *own_buf)
return;
}
size_t nbytes = (packet - start_of_text) / 2;
- char *user = (char *) xmalloc (nbytes + 1);
- nbytes = hex2bin (start_of_text, (gdb_byte *) user, nbytes);
- user[nbytes] = '\0';
+ gdb::unique_xmalloc_ptr<char> user ((char *) xmalloc (nbytes + 1));
+ nbytes = hex2bin (start_of_text, (gdb_byte *) user.get (), nbytes);
+ user.get ()[nbytes] = '\0';
++packet; /* skip the semicolon */
- trace_debug ("User is '%s'", user);
+ trace_debug ("User is '%s'", user.get ());
xfree (tracing_user_name);
- tracing_user_name = user;
+ tracing_user_name = user.release ();
}
else if (startswith (packet, "notes:"))
{
@@ -3973,13 +3963,13 @@ cmd_qtnotes (char *own_buf)
return;
}
size_t nbytes = (packet - start_of_text) / 2;
- char *notes = (char *) xmalloc (nbytes + 1);
- nbytes = hex2bin (start_of_text, (gdb_byte *) notes, nbytes);
- notes[nbytes] = '\0';
+ gdb::unique_xmalloc_ptr<char> notes ((char *) xmalloc (nbytes + 1));
+ nbytes = hex2bin (start_of_text, (gdb_byte *) notes.get (), nbytes);
+ notes.get ()[nbytes] = '\0';
++packet; /* skip the semicolon */
- trace_debug ("Notes is '%s'", notes);
+ trace_debug ("Notes is '%s'", notes.get ());
xfree (tracing_notes);
- tracing_notes = notes;
+ tracing_notes = notes.release ();
}
else if (startswith (packet, "tstop:"))
{
@@ -3993,13 +3983,15 @@ cmd_qtnotes (char *own_buf)
return;
}
size_t nbytes = (packet - start_of_text) / 2;
- char *stopnote = (char *) xmalloc (nbytes + 1);
- nbytes = hex2bin (start_of_text, (gdb_byte *) stopnote, nbytes);
- stopnote[nbytes] = '\0';
+ gdb::unique_xmalloc_ptr<char> stopnote
+ ((char *) xmalloc (nbytes + 1));
+ nbytes = hex2bin (start_of_text, (gdb_byte *) stopnote.get (),
+ nbytes);
+ stopnote.get ()[nbytes] = '\0';
++packet; /* skip the semicolon */
- trace_debug ("tstop note is '%s'", stopnote);
+ trace_debug ("tstop note is '%s'", stopnote.get ());
xfree (tracing_stop_note);
- tracing_stop_note = stopnote;
+ tracing_stop_note = stopnote.release ();
}
else
break;
--
2.25.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/5] gdbserver: prevent buffer overrun for QTDPsrc packet
2026-11-16 11:10 ` [PATCH 2/5] gdbserver: prevent buffer overrun for QTDPsrc packet Andrew Burgess
@ 2026-11-19 19:51 ` Keith Seitz
2026-11-23 17:15 ` Andrew Burgess
0 siblings, 1 reply; 10+ messages in thread
From: Keith Seitz @ 2026-11-19 19:51 UTC (permalink / raw)
To: Andrew Burgess, gdb-patches
Hi,
I just have a small style nit that I'd like to point
out. Nothing major here, and you are, of course, free
to ignore my Tcl pedantry.
On 11/16/26 3:10 AM, Andrew Burgess wrote:
> diff --git a/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
> new file mode 100644
> index 00000000000..d82647cbe63
> --- /dev/null
> +++ b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
> @@ -0,0 +1,141 @@
> +# This testcase is part of GDB, the GNU debugger.
> +#
> +# Copyright 2026 Free Software Foundation, Inc.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +
> +# Test some tracepoint related packets, focusing mostly on error
> +# handling within gdbserver. This does not test every tracepoint
> +# related packet. This test was written while fixing some bugs in
> +# various packets and the tests were only added for packets being
> +# fixed.
> +#
> +# Start gdbserver and connect. Use 'maint packet ...' to send
> +# tracepoint related packets to gdbserver. Some of these packets are
> +# valid, others are invalid.
> +#
> +# This manual packet sending is used in order to be able to send the
> +# invalid packets.
> +
> +load_lib gdbserver-support.exp
> +
> +require allow_gdbserver_tests
> +
> +standard_testfile normal.c
> +
> +if {[build_executable "failed to build" $testfile $srcfile]} {
> + return
> +}
> +
> +# Some global regexp used in the tests below.
> +set error_re "\r\nreceived: \"E01\""
> +set ok_re "\r\nreceived: \"OK\""
> +
> +# Start GDB and gdbserver ready for the test. Return false if
> +# anything goes wrong, otherwise, return true.
> +proc start_gdbserver_for_test {} {
> + clean_restart $::testfile
> +
> + # Make sure we're disconnected, in case we're testing with an
> + # extended-remote board, therefore already connected.
> + gdb_test "disconnect" ".*"
> +
> + # Start gdbserver and connect.
> + set res [gdbserver_spawn ""]
> + set gdbserver_protocol [lindex $res 0]
> + set gdbserver_gdbport [lindex $res 1]
List assignments to variables like this are more commonly done
with `lassign':
lassign $res gdbserver_protocol gdbserver_gdbport
[I did warn you! :-)]
> diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
> index e7c1f0c9e7f..00cbec8c8da 100644
> --- a/gdbserver/tracepoint.cc
> +++ b/gdbserver/tracepoint.cc
> @@ -2532,15 +2532,40 @@ cmd_qtdpsrc (char *own_buf)
> srctype[packet - start_of_type] = '\0';
> ++packet;
>
> + /* The QTDPsrc spec says that SLEN can be longer than the delivered string
> + in order to support strings longer than can fit in a single packet.
> + The START indicates where the string from this packet fits into the
> + overall string.
> +
> + However, gdbserver has never (yet) supported strings larger than a
> + single packet, which is why the START field here is ignored, and why we
> + check SLEN against the remaining packet length. */
> ULONGEST start, slen;
> packet = unpack_varlen_hex (packet, &start);
> ++packet; /* skip a colon */
> packet = unpack_varlen_hex (packet, &slen);
> ++packet; /* skip a colon */
> - char *src = (char *) xmalloc (slen + 1);
> - size_t nbytes = hex2bin (packet, (gdb_byte *) src, strlen (packet) / 2);
> +
> + size_t len = strlen (packet);
> + if (slen != len / 2 || len % 2 != 0)
> + {
> + trace_debug ("Tracepoint error: invalid string length %s in: %s",
> + pulongest (slen), own_buf);
> + write_enn (own_buf);
> + xfree (srctype);
> + return;
> + }
> +
> + char *src = (char *) xmalloc (len / 2 + 1);
> + size_t nbytes = hex2bin (packet, (gdb_byte *) src,
> + static_cast<int> (len / 2));
> src[nbytes] = '\0';
Just for the record, hex2bin can throw, so this can leak
`src', but you fix this in patch 5/5. I don't know if this is
worth mentioning in the commit message for someone reviewing
this patch in the future?
Keith
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet
2026-11-16 11:10 [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet Andrew Burgess
` (4 preceding siblings ...)
2026-11-16 11:10 ` [PATCH 5/5] gdbserver: use unique_xmalloc_ptr to avoid memory leaks Andrew Burgess
@ 2026-11-19 19:52 ` Keith Seitz
5 siblings, 0 replies; 10+ messages in thread
From: Keith Seitz @ 2026-11-19 19:52 UTC (permalink / raw)
To: Andrew Burgess, gdb-patches
Hi,
On 11/16/26 3:10 AM, Andrew Burgess wrote:
> This started as a simple patch to fix a buffer overflow in QTDPsrc
> (patch #2). But grew a little along the way.
>
> Patch #1 is a general spring clean of the code I ended up touching.
>
> Then patches #3, #4, and #5 fix additional issues that I spotted along
> the way.
Thanks a bunch for fixing these problems.
I've taken a look at everything, and it all looks pretty good
to me. A major step toward hardening this code.
I just have some really minor nits which you should feel free
to ignore.
Reviewed-By: Keith Seitz <keiths@redhat.com>
Keith
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/5] gdbserver: prevent buffer overrun for QTDPsrc packet
2026-11-19 19:51 ` Keith Seitz
@ 2026-11-23 17:15 ` Andrew Burgess
2026-11-23 17:57 ` Keith Seitz
0 siblings, 1 reply; 10+ messages in thread
From: Andrew Burgess @ 2026-11-23 17:15 UTC (permalink / raw)
To: Keith Seitz, gdb-patches
Keith Seitz <keiths@redhat.com> writes:
> Hi,
>
> I just have a small style nit that I'd like to point
> out. Nothing major here, and you are, of course, free
> to ignore my Tcl pedantry.
>
> On 11/16/26 3:10 AM, Andrew Burgess wrote:
>> diff --git a/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
>> new file mode 100644
>> index 00000000000..d82647cbe63
>> --- /dev/null
>> +++ b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
>> @@ -0,0 +1,141 @@
>> +# This testcase is part of GDB, the GNU debugger.
>> +#
>> +# Copyright 2026 Free Software Foundation, Inc.
>> +#
>> +# This program is free software; you can redistribute it and/or modify
>> +# it under the terms of the GNU General Public License as published by
>> +# the Free Software Foundation; either version 3 of the License, or
>> +# (at your option) any later version.
>> +#
>> +# This program is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> +# GNU General Public License for more details.
>> +#
>> +# You should have received a copy of the GNU General Public License
>> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
>> +
>> +# Test some tracepoint related packets, focusing mostly on error
>> +# handling within gdbserver. This does not test every tracepoint
>> +# related packet. This test was written while fixing some bugs in
>> +# various packets and the tests were only added for packets being
>> +# fixed.
>> +#
>> +# Start gdbserver and connect. Use 'maint packet ...' to send
>> +# tracepoint related packets to gdbserver. Some of these packets are
>> +# valid, others are invalid.
>> +#
>> +# This manual packet sending is used in order to be able to send the
>> +# invalid packets.
>> +
>> +load_lib gdbserver-support.exp
>> +
>> +require allow_gdbserver_tests
>> +
>> +standard_testfile normal.c
>> +
>> +if {[build_executable "failed to build" $testfile $srcfile]} {
>> + return
>> +}
>> +
>> +# Some global regexp used in the tests below.
>> +set error_re "\r\nreceived: \"E01\""
>> +set ok_re "\r\nreceived: \"OK\""
>> +
>> +# Start GDB and gdbserver ready for the test. Return false if
>> +# anything goes wrong, otherwise, return true.
>> +proc start_gdbserver_for_test {} {
>> + clean_restart $::testfile
>> +
>> + # Make sure we're disconnected, in case we're testing with an
>> + # extended-remote board, therefore already connected.
>> + gdb_test "disconnect" ".*"
>> +
>> + # Start gdbserver and connect.
>> + set res [gdbserver_spawn ""]
>> + set gdbserver_protocol [lindex $res 0]
>> + set gdbserver_gdbport [lindex $res 1]
>
> List assignments to variables like this are more commonly done
> with `lassign':
>
> lassign $res gdbserver_protocol gdbserver_gdbport
>
> [I did warn you! :-)]
I'll change this as you suggest, see the updated patch below.
>
>> diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
>> index e7c1f0c9e7f..00cbec8c8da 100644
>> --- a/gdbserver/tracepoint.cc
>> +++ b/gdbserver/tracepoint.cc
>> @@ -2532,15 +2532,40 @@ cmd_qtdpsrc (char *own_buf)
>> srctype[packet - start_of_type] = '\0';
>> ++packet;
>>
>> + /* The QTDPsrc spec says that SLEN can be longer than the delivered string
>> + in order to support strings longer than can fit in a single packet.
>> + The START indicates where the string from this packet fits into the
>> + overall string.
>> +
>> + However, gdbserver has never (yet) supported strings larger than a
>> + single packet, which is why the START field here is ignored, and why we
>> + check SLEN against the remaining packet length. */
>> ULONGEST start, slen;
>> packet = unpack_varlen_hex (packet, &start);
>> ++packet; /* skip a colon */
>> packet = unpack_varlen_hex (packet, &slen);
>> ++packet; /* skip a colon */
>> - char *src = (char *) xmalloc (slen + 1);
>> - size_t nbytes = hex2bin (packet, (gdb_byte *) src, strlen (packet) / 2);
>> +
>> + size_t len = strlen (packet);
>> + if (slen != len / 2 || len % 2 != 0)
>> + {
>> + trace_debug ("Tracepoint error: invalid string length %s in: %s",
>> + pulongest (slen), own_buf);
>> + write_enn (own_buf);
>> + xfree (srctype);
>> + return;
>> + }
>> +
>> + char *src = (char *) xmalloc (len / 2 + 1);
>> + size_t nbytes = hex2bin (packet, (gdb_byte *) src,
>> + static_cast<int> (len / 2));
>> src[nbytes] = '\0';
>
> Just for the record, hex2bin can throw, so this can leak
> `src', but you fix this in patch 5/5. I don't know if this is
> worth mentioning in the commit message for someone reviewing
> this patch in the future?
I fix this in patch #5. I have added some additional text to the commit
message to acknowledge that this bug exists, and explain that it is
fixed in a later patch. See the updated patch below.
Let me know what you think.
Thanks,
Andrew
---
commit d5f102b72ca7644cfad07691ff6ed8203ddb41eb
Author: Andrew Burgess <aburgess@redhat.com>
Date: Thu Nov 12 10:59:54 2026 +0000
gdbserver: prevent buffer overrun for QTDPsrc packet
The QTDPsrc packet format is:
QTDPsrc:N:ADDR:TYPE:START:SLEN:BYTES
The BYTES is a hex encoded string. The START and SLEN allow for
strings that are longer than a single packet, START is the position of
BYTES within the full string, and SLEN is the length of the full
string.
Critically, the hex decoding of BYTES might not equal SLEN.
The current handling of QTDPsrc makes two errors: it allocates a
buffer based on SLEN. A malicious incoming packet could include an
arbitrarily large SLEN value causing gdbserver to allocate a huge
amount of memory. This would either cause the gdbserver process to
terminate with an out of memory error, or might bring down the machine
due to memory pressure.
The second problem is that gdbserver converts bytes from the packet
into the allocated buffer using a call to hex2bin, and uses the packet
length as the limit on the number of bytes translated. This means
that if SLEN is less than the length of the hex decoded string,
gdbserver will overflow the allocated buffer and write to arbitrary
memory.
This commit makes the following changes:
1. Ensure that SLEN matches the length of the hex decoded BYTES
string.
I did consider just ignoring SLEN, but that means gdbserver would
accept invalid packets, e.g. SLEN less than the length of the hex
decoded BYTES string. And that seemed like a bad idea.
2. Allocate the buffer, and cap the hex2bin call based on the length
of the hex decoded BYTES string, not SLEN. This means that if
the rules for SLEN change in the future the buffer will be the
right size to decode BYTES.
One point of interest is that I added a call `xfree (srctype)` on the
error path. This avoids leaking a previously allocated buffer. This
is temporary, a later commit in this series switches the buffer to use
gdb::unique_xmalloc_ptr<char> instead and the xfree will be removed.
Adding the xfree now just means this commit can be more focused.
Additionally there are existing memory leaks in the code, buffers
allocated with xmalloc can be leaked if hex2bin throws an
exception (which it does if it encounters a non-hex character). These
leaks are resolved by a later patch in this series.
The header comment in the new test script, and the name of the script
itself, both indicate that this script is for testing more than the
QTDPsrc packet. Right now this is not the case, but later commits in
this series will add more tests. I've left the header comment as
generic text that talks about testing multiple tracepoint packets to
avoid churn in the next commit.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34968
diff --git a/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
new file mode 100644
index 00000000000..9b585d4de46
--- /dev/null
+++ b/gdb/testsuite/gdb.server/invalid-tracepoint-packets.exp
@@ -0,0 +1,140 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2026 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test some tracepoint related packets, focusing mostly on error
+# handling within gdbserver. This does not test every tracepoint
+# related packet. This test was written while fixing some bugs in
+# various packets and the tests were only added for packets being
+# fixed.
+#
+# Start gdbserver and connect. Use 'maint packet ...' to send
+# tracepoint related packets to gdbserver. Some of these packets are
+# valid, others are invalid.
+#
+# This manual packet sending is used in order to be able to send the
+# invalid packets.
+
+load_lib gdbserver-support.exp
+
+require allow_gdbserver_tests
+
+standard_testfile normal.c
+
+if {[build_executable "failed to build" $testfile $srcfile]} {
+ return
+}
+
+# Some global regexp used in the tests below.
+set error_re "\r\nreceived: \"E01\""
+set ok_re "\r\nreceived: \"OK\""
+
+# Start GDB and gdbserver ready for the test. Return false if
+# anything goes wrong, otherwise, return true.
+proc start_gdbserver_for_test {} {
+ clean_restart $::testfile
+
+ # Make sure we're disconnected, in case we're testing with an
+ # extended-remote board, therefore already connected.
+ gdb_test "disconnect" ".*"
+
+ # Start gdbserver and connect.
+ set res [gdbserver_spawn ""]
+ lassign $res gdbserver_protocol gdbserver_gdbport
+ set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
+ if {![gdb_assert {$res == 0} "connect"]} {
+ return false
+ }
+
+ return true
+}
+
+# Test the QTDPsrc packet.
+proc_with_prefix test_qtdpsrc {} {
+ if {![start_gdbserver_for_test]} {
+ return
+ }
+
+ # Disassemble main and find an address at which we could place a
+ # tracepoint.
+ set addresses {}
+ gdb_test_multiple "disassemble main" "" -lbl {
+ -re "\r\n\\s+0x0*(\[0-9a-f\]+)\\s+\[^\r\n\]+(?=\r\n)" {
+ set addr $expect_out(1,string)
+ lappend addresses $addr
+ exp_continue
+ }
+
+ -re "^\r\n$::gdb_prompt $" {
+ gdb_assert {[llength $addresses] > 0} \
+ "found instruction addresses"
+ }
+ }
+
+ # We need at least one address in main for this test.
+ if {[llength $addresses] < 1} {
+ unsupported "not enough instruction addresses in main"
+ gdbserver_exit false
+ return
+ }
+
+ # Record the address we'll use in this test.
+ set addr [lindex $addresses 0]
+
+ # Create a tracepoint at ADDR. Do this manually as the rest of this
+ # test also does manual packet manipulation.
+ gdb_test_multiple "maint packet QTDP:1:$addr:D:1:1" "create tracepoint" {
+ -re -wrap "\r\nreceived: \"OK\"" {
+ pass $gdb_test_name
+ }
+
+ -re -wrap "" {
+ unsupported $gdb_test_name
+ gdbserver_exit false
+ return
+ }
+ }
+
+ # Now send invalid QTDPsrc packets at gdbserver and check they are all
+ # rejected.
+ set prefix "QTDPsrc:1:$addr:cond:0"
+
+ # Undersized strings. The packet declares that it has a string
+ # containing 2 bytes, but COUNT is the actual number of nibbles
+ # supplied.
+ foreach count {0 1 2 3} {
+ gdb_test "maint packet ${prefix}:2:[string repeat 1 $count]" \
+ $::error_re "string of $count nibbles and declared length 2 bytes"
+ }
+
+ # Packets with oversized strings of various sizes. The packet
+ # declares that it has a string containing 1 byte, but COUNT is the
+ # actual number of nibbles supplied.
+ foreach count {3 100 500 1000 2000 4000} {
+ gdb_test "maint packet ${prefix}:1:[string repeat 1 $count]" \
+ $::error_re "string of $count nibbles and declared length 1 byte"
+ }
+
+ # Test some valid packets.
+ gdb_test "maint packet ${prefix}:1:41" $::ok_re "valid string accepted"
+ gdb_test "maint packet ${prefix}:3:414243" $::ok_re \
+ "valid multi-byte string accepted"
+ gdb_test "maint packet ${prefix}:0:" $::ok_re "empty string accepted"
+
+ gdbserver_exit false
+}
+
+test_qtdpsrc
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index e7c1f0c9e7f..00cbec8c8da 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -2532,15 +2532,40 @@ cmd_qtdpsrc (char *own_buf)
srctype[packet - start_of_type] = '\0';
++packet;
+ /* The QTDPsrc spec says that SLEN can be longer than the delivered string
+ in order to support strings longer than can fit in a single packet.
+ The START indicates where the string from this packet fits into the
+ overall string.
+
+ However, gdbserver has never (yet) supported strings larger than a
+ single packet, which is why the START field here is ignored, and why we
+ check SLEN against the remaining packet length. */
ULONGEST start, slen;
packet = unpack_varlen_hex (packet, &start);
++packet; /* skip a colon */
packet = unpack_varlen_hex (packet, &slen);
++packet; /* skip a colon */
- char *src = (char *) xmalloc (slen + 1);
- size_t nbytes = hex2bin (packet, (gdb_byte *) src, strlen (packet) / 2);
+
+ size_t len = strlen (packet);
+ if (slen != len / 2 || len % 2 != 0)
+ {
+ trace_debug ("Tracepoint error: invalid string length %s in: %s",
+ pulongest (slen), own_buf);
+ write_enn (own_buf);
+ xfree (srctype);
+ return;
+ }
+
+ char *src = (char *) xmalloc (len / 2 + 1);
+ size_t nbytes = hex2bin (packet, (gdb_byte *) src,
+ static_cast<int> (len / 2));
src[nbytes] = '\0';
+ /* Because we check SLEN against the packet length above, either the packet
+ is fully parsed, or hex2bin will have thrown an error on seeing a
+ non-hex character. */
+ gdb_assert (packet[nbytes * 2] == '\0');
+
struct source_string *newlast = XNEW (struct source_string);
newlast->type = srctype;
newlast->str = src;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/5] gdbserver: prevent buffer overrun for QTDPsrc packet
2026-11-23 17:15 ` Andrew Burgess
@ 2026-11-23 17:57 ` Keith Seitz
0 siblings, 0 replies; 10+ messages in thread
From: Keith Seitz @ 2026-11-23 17:57 UTC (permalink / raw)
To: Andrew Burgess, gdb-patches
Hi,
On 11/23/26 9:15 AM, Andrew Burgess wrote:
> Keith Seitz <keiths@redhat.com> writes:
>>> + char *src = (char *) xmalloc (len / 2 + 1);
>>> + size_t nbytes = hex2bin (packet, (gdb_byte *) src,
>>> + static_cast<int> (len / 2));
>>> src[nbytes] = '\0';
>>
>> Just for the record, hex2bin can throw, so this can leak
>> `src', but you fix this in patch 5/5. I don't know if this is
>> worth mentioning in the commit message for someone reviewing
>> this patch in the future?
>
> I fix this in patch #5. I have added some additional text to the commit
> message to acknowledge that this bug exists, and explain that it is
> fixed in a later patch. See the updated patch below.
All LGTM. Thanks!
Reviewed-By: Keith Seitz <keiths@redhat.com>
Keith
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-11-23 17:57 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 11:10 [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet Andrew Burgess
2026-11-16 11:10 ` [PATCH 1/5] gdbserver: clean up some older code in tracepoint.cc Andrew Burgess
2026-11-16 11:10 ` [PATCH 2/5] gdbserver: prevent buffer overrun for QTDPsrc packet Andrew Burgess
2026-11-19 19:51 ` Keith Seitz
2026-11-23 17:15 ` Andrew Burgess
2026-11-23 17:57 ` Keith Seitz
2026-11-16 11:10 ` [PATCH 3/5] gdbserver: improve packet parsing in tracepoint.cc Andrew Burgess
2026-11-16 11:10 ` [PATCH 4/5] gdbserver: don't leak trace variable names if reusing variable numbers Andrew Burgess
2026-11-16 11:10 ` [PATCH 5/5] gdbserver: use unique_xmalloc_ptr to avoid memory leaks Andrew Burgess
2026-11-19 19:52 ` [PATCH 0/5] gdbserver: fix buffer overflow issue in QTDPsrc packet Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox