From 9c60b339dad849e8d554579a0c3141f9ed9c1ca0 Mon Sep 17 00:00:00 2001 From: ALTracer <11005378+ALTracer@users.noreply.github.com> Date: Mon, 6 Jan 2025 06:11:30 +0300 Subject: [PATCH] gdb_main: Restore m-packet request-length check * Its purpose is to ensure that potential responses fit into RSP packet buffer * Suppresses unexpected E02 responses on reading small SRAM/Flash variables * Still enforces E02 to 513 byte read requests or larger --- src/gdb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gdb_main.c b/src/gdb_main.c index dc145247cc9..2c405a4260d 100644 --- a/src/gdb_main.c +++ b/src/gdb_main.c @@ -145,7 +145,7 @@ int32_t gdb_main_loop(target_controller_s *const tc, const gdb_packet_s *const p uint32_t addr, len; ERROR_IF_NO_TARGET(); if (read_hex32(packet->data + 1, &rest, &addr, ',') && read_hex32(rest, NULL, &len, READ_HEX_NO_FOLLOW)) { - if (len > packet->size / 2U) { + if (len > GDB_PACKET_BUFFER_SIZE / 2U) { gdb_put_packet_error(2U); break; }