From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wWhrG1cIAGtHTCMAWB0awg (envelope-from ) for ; Fri, 20 Nov 2026 03:44:07 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UbdqPzvh; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 6AA1F1E0BC; Fri, 20 Nov 2026 03:44:07 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 057A11E087 for ; Fri, 20 Nov 2026 03:44:06 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 992664B1969A for ; Fri, 20 Nov 2026 08:44:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 992664B1969A Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UbdqPzvh Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 766204AA51CE for ; Fri, 20 Nov 2026 08:43:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 766204AA51CE Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 766204AA51CE Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795164209; cv=none; b=Y1uw0AR8pHVZx2LxZ99lRZ1oBiDrrz6IPLfp8rvhjFgj4vTxrhmtHyhXDZjpRLA1OG5C1u7kWpdBZL92/UpFHrhuOfCZFnbGalJY2VlfjN5GUBAznIkLhp262QecnTnVQ67dD0sWn3s0fFEy6QQTKQinp/+z2wsQlH3bdnjrupM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795164209; c=relaxed/simple; bh=FGYweN1JXP17srGoVa6cw/SuhnyqJh06jrSfDerKqDI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NfHqVzPAbZOkKX+Lr+lXH22ksuaFQfyZyiVSUiz5SslPEBCXJIen8HZnpT5StwYbIp6RrY5Mn0wQ1Xlpaga5/F+uSxNsM4FNlHNgbRQAfPj3L/iZtBSWbRR7Etrv8jPUB4fY541dWYRlJj0Dy928IvnXb83IMtasV4S06rgvSOo= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UbdqPzvh DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 766204AA51CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795164208; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2n5mnfYAzSjKk81UzPqGDRUb9jlBXMcVC8UX1OG4VXI=; b=UbdqPzvhvFQd+T848JM0qsfyiBy2q6IDYV6NWtaD/C+gV7rD9No8Iw7RN3jxShkfeONLEQ Oc4CjXrLTmip7k50j7UDOicyht6m+R9IDkymPmc1It8qklw1tgSfR8EuN8T+24tHiRhDPP TgnLFUhOok+2BqgJbb7aZNgadtb4k3M= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-507-q1icz5prM9K5FB6ItYUpsA-1; Fri, 20 Nov 2026 08:43:25 +0000 X-MC-Unique: q1icz5prM9K5FB6ItYUpsA-1 X-Mimecast-MFC-AGG-ID: q1icz5prM9K5FB6ItYUpsA_1795164205 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C98C01800372 for ; Fri, 20 Nov 2026 08:43:24 +0000 (UTC) Received: from kevinb-defaultstring.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C81AE195B3C4; Fri, 20 Nov 2026 08:43:23 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Kevin Buettner Subject: [PATCH v2 1/1] gdbserver: reject malformed agent expressions in gdb_parse_agent_expr Date: Fri, 20 Nov 2026 01:14:05 -0700 Message-ID: <20261120084131.659727-3-kevinb@redhat.com> In-Reply-To: <20261120084131.659727-2-kevinb@redhat.com> References: <20261120084131.659727-2-kevinb@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vvYovnXRcGilfPTMspUGirajI6hlkNScbC79dO3BNnc_1795164205 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org gdb_parse_agent_expr, defined in gdbserver/ax.cc, is called from four different sites within gdbserver, two from mem-break.cc and two from tracepoint.cc. Within tracepoint.cc, gdb_parse_agent_expr is called to handle the 'X' portion of a QTDP packet. The 'X' portion describes agent expressions used by tracepoints for both conditions and actions. Within mem-break.cc, it's called to handle breakpoint conditions or commands as part of a 'Z' packet. These conditions or commands are specified in a bytecode format identical to that used for agent expressions for tracepoints. The current implementation of gdb_parse_agent_expr contains no checks about validity of the length specified in the portion of a packet that represents an agent expression. This takes the form "X,". (This is not an 'X' packet but, rather, a portion of the 'QTDP' packet for tracepoints or 'Z0' packet for breakpoints.) gdb_parse_agent_expr allocates LEN bytes and asks hex2bin to convert that number of bytes, but hex2bin stops at the end of the packet, leaving the end of the buffer uninitialized. For a tracepoint condition, that buffer is later sent back to GDB in reply to qTfP/qTsP, which are used to request tracepoint data. Thus, using an overly large length can provide access to uninitialized gdbserver heap memory, a potential security concern. The parse pointer is also advanced by 2 * LEN bytes regardless of how much data was present, so callers continue parsing from a pointer that can be far beyond the end of the packet; a large LEN crashes gdbserver. Fix this by having gdb_parse_agent_expr return nullptr (representing an error condition) when the specified length exceeds the amount of hex data actually present. This code also wasn't checking for the mandated comma character in the packet syntax. I added a check and error return for that too. The remainder of this patch to gdbserver consists of propagating the error back to various points in the code where write_enn may be called. This causes the error to be sent as the reply to GDB. For Z0 packet support, I removed two warning messages. One concerned a malformed condition and the other was about a malformed action (command). A malformed condition was discarded, making the breakpoint unconditional; similarly, a malformed action was simply dropped. The warning message (which might not even be seen by the user) stated these facts. gdbserver now returns an error response for these cases. The test case uses GDB's little-used "maintenance packet" command to send bad packets to gdbserver. This has been done not only for the tracepoint related packets, but for the Z0 (set breakpoint) packet as well. Z0 used to silently drop malformed packets and set a breakpoint without the (presumably intended, but malformed) condition or action. It no longer does this. Malformed conditions and actions within a Z0 packet now cause an error to be returned. While working on this patch, I spotted numerous other problems in nearby code (e.g. memory leaks and lack of packet syntax checking). I left these alone. gdbserver desperately needs attention to fix myriad problems. This fixes the bug associated with CVE-2026-121996. Regression tested on x86_64 Fedora 44. The new test case was tested on RISC-V Fedora 42, for which neither Z0 packets nor tracepoint packets are implemented. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34969 --- .../gdb.server/agent-expr-length.exp | 215 ++++++++++++++++++ gdbserver/ax.cc | 13 +- gdbserver/ax.h | 4 +- gdbserver/mem-break.cc | 10 +- gdbserver/server.cc | 27 ++- gdbserver/tracepoint.cc | 25 +- 6 files changed, 272 insertions(+), 22 deletions(-) create mode 100644 gdb/testsuite/gdb.server/agent-expr-length.exp diff --git a/gdb/testsuite/gdb.server/agent-expr-length.exp b/gdb/testsuite/gdb.server/agent-expr-length.exp new file mode 100644 index 00000000000..d9e1db7865c --- /dev/null +++ b/gdb/testsuite/gdb.server/agent-expr-length.exp @@ -0,0 +1,215 @@ +# 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 . + +# Send a variety of malformed Z0 and QTDP packets to gdbserver. These +# malformed packets could, at one time, crash gdbserver or provide access +# to its memory. + +load_lib gdbserver-support.exp + +require allow_gdbserver_tests + +standard_testfile normal.c + +if {[build_executable "failed to prepare" $testfile $srcfile]} { + return +} + +# Send a packet to gdbserver using "maintenance packet". Returns the +# response from gdbserver. +proc maint_packet { packet testname } { + set answer "" + gdb_test_multiple "maintenance packet $packet" $testname { + -re -wrap {received: "([^"]*)"} { + set answer $expect_out(1,string) + } + } + return $answer +} + +# Do the routine things needed to set up gdbserver. +proc prepare_server { } { + clean_restart $::testfile + gdb_test "disconnect" ".*" + gdbserver_run "" +} + +# Send out Z0 / z0 (breakpoint) packets for this test. Use "main" for the +# address at which to place the breakpoint. +proc test_Z0 {exp testname} { + with_test_prefix $testname { + prepare_server + set addr [format %x [get_hexadecimal_valueof "&main" 0]] + + set result [maint_packet "Z0,$addr,1;$exp" "maint packet Z0"] + gdb_assert {[regexp {^E\d\d} $result]} "Z0 packet returns error" + + # Check that a failed insert didn't leave a breakpoint. + set result [maint_packet "z0,$addr,1" "maint packet z0"] + gdb_assert {[regexp {^E\d\d} $result]} \ + "z0 packet confirms breakpoint was not inserted" + } +} + +# Send/receive tracepoint related packets for this test. +proc test_QTDP {cond action testname} { + with_test_prefix $testname { + prepare_server + set addr [format %x [get_hexadecimal_valueof "&main" 0]] + + set result [maint_packet "QTinit" "maint packet QTinit"] + gdb_assert {$result eq "OK"} "QTinit packet returns OK" + + set pcond "" + set pcont "" + if { $cond ne "" } { + set pcond ":$cond" + } + if { $action ne "" } { + set pcont "-" + } + + set result \ + [maint_packet "QTDP:1:$addr:E:0:0$pcond$pcont" "maint packet QTDP"] + if {$pcond eq ""} { + gdb_assert {$result eq "OK"} "QTDP packet returns OK" + } else { + gdb_assert {[regexp {^E\d\d} $result]} "QTDP packet returns error" + } + + if { $action ne "" } { + set result [maint_packet "QTDP:-1:$addr:$action" \ + "maint packet QTDP continuation"] + gdb_assert {[regexp {^E\d\d} $result]} \ + "QTDP continuation packet returns error" + } + + set result [maint_packet "qTfP" "maint packet qTfP"] + gdb_assert {$result eq "l"} "tracepoint list is empty" + } +} + +# Check whether gdbserver supports the Z0 packet; return 1 if so, otherwise +# return 0 and show that tests involving Z0 packets are unsupported. +proc check_Z0_breakpoint_support {} { + with_test_prefix "check Z0 support" { + prepare_server + set addr [format %x [get_hexadecimal_valueof "&main" 0]] + + # The hex agent expression below pushes 1 onto the evaluation stack + # and then returns it. + set result [maint_packet "Z0,$addr,1;X03,220127" "maint packet Z0"] + if {$result eq ""} { + unsupported "Z0 packets" + return 0 + } + gdb_assert {$result eq "OK"} "Z0 packet returns OK" + + # Attempt to delete the breakpoint created above. Probably + # overkill, but we'll note it as unsupported if it doesn't work. + set result [maint_packet "z0,$addr,1" "maint packet z0"] + if {$result eq ""} { + unsupported "z0 packets" + return 0 + } + gdb_assert {$result eq "OK"} "z0 packet returns OK" + + return 1 + } +} + +# Tracepoint support predicate; this one just checks whether QTinit works. +# Return 0 and show an "unsupported" message if not supported; otherwise +# return 1 when supported. +proc check_tracepoint_support {} { + with_test_prefix "check tracepoint support" { + prepare_server + set addr [format %x [get_hexadecimal_valueof "&main" 0]] + + set result [maint_packet "QTinit" "maint packet QTinit"] + if {$result eq ""} { + unsupported "tracepoints" + return 0 + } + + gdb_assert {$result eq "OK"} "QTinit packet returns OK" + + # Check that a valid expression passes; the agent expression pushes + # 1 and returns it. + set result [maint_packet "QTDP:1:$addr:E:0:0:X03,220127" \ + "good maint packet QTDP"] + gdb_assert {$result eq "OK"} "good maint packet QTDP returns OK" + + # Fetch the tracepoint list; it should contain the tracepoint + # defined above. + set result [maint_packet "qTfP" "maint packet qTfP"] + gdb_assert {[regexp {^T1:} $result]} "tracepoint list is not empty" + return 1 + } +} + +# Conditions for both Z0 and QTDP packets. Note that "cc" and "ee" aren't +# real opcodes. This does not matter because each of these expressions is +# malformed in some way. +set large_cond "X20,cc" +set huge_cond "X800000,cc" +set no_comma_cond "X04" + +# Z0 commands: +set large_exp "cmds:0,X20,ee" +set huge_exp "cmds:0,X800000,ee" +set no_comma_exp "cmds:0,X04" + +# QTDP actions: +set large_action "X20,ee" +set huge_action "X800000,ee" +set no_comma_action "X04" + +if {[check_Z0_breakpoint_support]} { + with_test_prefix "breakpoint tests" { + test_Z0 $large_cond "over-long condition" + test_Z0 $huge_cond "massively over-long condition" + test_Z0 $no_comma_cond "missing comma before condition" + test_Z0 $large_exp "over-long expression" + test_Z0 $huge_exp "massively over-long expression" + test_Z0 $no_comma_exp "missing comma before expression" + } +} + +if {[check_tracepoint_support]} { + with_test_prefix "tracepoint tests" { + test_QTDP $large_cond "" "over-long condition" + test_QTDP $huge_cond "" "massively over-long condition" + test_QTDP $no_comma_cond "" "missing comma before condition" + + test_QTDP "" $large_action "over-long action" + test_QTDP "" $huge_action "massively over-long action" + test_QTDP "" $no_comma_action "missing comma before action" + + test_QTDP $large_cond $large_action \ + "over-long condition and over-long action" + test_QTDP $large_cond $huge_action \ + "over-long condition and massively over-long action" + test_QTDP $large_cond $no_comma_action \ + "over-long condition and missing comma before action" + + test_QTDP $huge_cond $large_action \ + "massively over-long condition and over-long action" + test_QTDP $huge_cond $huge_action \ + "massively over-long condition and massively over-long action" + test_QTDP $huge_cond $no_comma_action \ + "massively over-long condition and missing comma before action" + } +} diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc index 4993bed2532..f73a407f70a 100644 --- a/gdbserver/ax.cc +++ b/gdbserver/ax.cc @@ -91,8 +91,7 @@ gdb_agent_op_name (int op) #ifndef IN_PROCESS_AGENT -/* The packet form of an agent expression consists of an 'X', number - of bytes in expression, a comma, and then the bytes. */ +/* See ax.h. */ struct agent_expr * gdb_parse_agent_expr (const char **actparm) @@ -103,7 +102,15 @@ gdb_parse_agent_expr (const char **actparm) ++act; /* skip the X */ act = unpack_varlen_hex (act, &xlen); - ++act; /* skip a comma */ + + if (*act != ',') + return nullptr; + ++act; /* skip the comma */ + + /* Return error if provided length exceeds size of actual hex string. */ + if (xlen > ((ULONGEST) strspn (act, "0123456789abcdefABCDEF") / 2)) + return nullptr; + aexpr = XNEW (struct agent_expr); aexpr->length = xlen; aexpr->bytes = (unsigned char *) xmalloc (xlen); diff --git a/gdbserver/ax.h b/gdbserver/ax.h index 03882f4888a..7ad077f8195 100644 --- a/gdbserver/ax.h +++ b/gdbserver/ax.h @@ -48,7 +48,9 @@ struct agent_expr #ifndef IN_PROCESS_AGENT /* The packet form of an agent expression consists of an 'X', number - of bytes in expression, a comma, and then the bytes. */ + of bytes in expression, a comma, and then the bytes. Parse one at + *ACTPARM, advancing *ACTPARM past it. Return nullptr, leaving + *ACTPARM unchanged, if the expression is malformed. */ struct agent_expr *gdb_parse_agent_expr (const char **actparm); /* Release an agent expression. */ diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc index 4e944ff1df2..071f8330c50 100644 --- a/gdbserver/mem-break.cc +++ b/gdbserver/mem-break.cc @@ -1205,10 +1205,7 @@ add_breakpoint_condition (struct gdb_breakpoint *bp, const char **condition) cond = gdb_parse_agent_expr (&actparm); if (cond == NULL) - { - warning (_("Condition evaluation failed. Assuming unconditional.")); - return 0; - } + return 0; add_condition_to_breakpoint (bp, cond); @@ -1304,10 +1301,7 @@ add_breakpoint_commands (struct gdb_breakpoint *bp, const char **command, cmd = gdb_parse_agent_expr (&actparm); if (cmd == NULL) - { - warning (_("Command evaluation failed. Disabling.")); - return 0; - } + return 0; add_commands_to_breakpoint (bp, cmd, persist); diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 7bd725f81ed..ac300eee084 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -4744,17 +4744,20 @@ main (int argc, char *argv[]) /* Process options coming from Z packets for a breakpoint. PACKET is the packet buffer. *PACKET is updated to point to the first char - after the last processed option. */ + after the last processed option. Return true on success and false + if caller should report an error. */ -static void +static bool process_point_options (struct gdb_breakpoint *bp, const char **packet) { const char *dataptr = *packet; int persist; - /* Check if data has the correct format. */ + /* Return success if the next character is not semicolon; the semicolon + introduces optional conditional and/or bytecode expressions to + evaluate/execute. */ if (*dataptr != ';') - return; + return true; dataptr++; @@ -4768,7 +4771,7 @@ process_point_options (struct gdb_breakpoint *bp, const char **packet) /* Conditional expression. */ threads_debug_printf ("Found breakpoint condition."); if (!add_breakpoint_condition (bp, &dataptr)) - dataptr = strchrnul (dataptr, ';'); + return false; } else if (startswith (dataptr, "cmds:")) { @@ -4776,8 +4779,9 @@ process_point_options (struct gdb_breakpoint *bp, const char **packet) threads_debug_printf ("Found breakpoint commands %s.", dataptr); persist = (*dataptr == '1'); dataptr += 2; - if (add_breakpoint_commands (bp, &dataptr, persist)) - dataptr = strchrnul (dataptr, ';'); + if (!add_breakpoint_commands (bp, &dataptr, persist)) + return false; + dataptr = strchrnul (dataptr, ';'); } else { @@ -4788,6 +4792,7 @@ process_point_options (struct gdb_breakpoint *bp, const char **packet) } } *packet = dataptr; + return true; } /* Event loop callback that handles a serial event. The first byte in @@ -5058,7 +5063,13 @@ process_serial_event (void) instead. */ clear_breakpoint_conditions_and_commands (bp); const char *options = dataptr; - process_point_options (bp, &options); + if (!process_point_options (bp, &options)) + { + /* Error: remove breakpoint and write error. */ + delete_gdb_breakpoint (type, addr, kind); + write_enn (cs.own_buf); + break; + } } } else diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc index 6f657257ee8..4cd1722869b 100644 --- a/gdbserver/tracepoint.cc +++ b/gdbserver/tracepoint.cc @@ -1802,7 +1802,7 @@ find_next_tracepoint_by_number (struct tracepoint *prev_tp, int num) /* Append another action to perform when the tracepoint triggers. */ -static void +static bool add_tracepoint_action (struct tracepoint *tpoint, const char *packet) { const char *act; @@ -1877,6 +1877,11 @@ add_tracepoint_action (struct tracepoint *tpoint, const char *packet) trace_debug ("Want to evaluate expression"); xaction->expr = gdb_parse_agent_expr (&act); + if (xaction->expr == nullptr) + { + free (xaction); + return false; + } break; } default: @@ -1916,6 +1921,7 @@ add_tracepoint_action (struct tracepoint *tpoint, const char *packet) = savestring (act_start, act - act_start); } } + return true; } #endif @@ -2404,6 +2410,13 @@ cmd_qtdp (char *own_buf) else if (*packet == 'X') { tpoint->cond = gdb_parse_agent_expr (&packet); + if (tpoint->cond == nullptr) + { + trace_debug ("Malformed agent expression for conditional"); + write_enn (own_buf); + remove_tracepoint (tpoint); + return; + } } else if (*packet == '-') break; @@ -2425,7 +2438,15 @@ cmd_qtdp (char *own_buf) tpoint->step_count, tpoint->pass_count); } else if (tpoint) - add_tracepoint_action (tpoint, packet); + { + if (!add_tracepoint_action (tpoint, packet)) + { + trace_debug ("Malformed tracepoint action"); + write_enn (own_buf); + remove_tracepoint (tpoint); + return; + } + } else { trace_debug ("Tracepoint error: tracepoint %d at 0x%s not found", -- 2.56.1