Skip to content

Commit

Permalink
gdb_main: Restore m-packet request-length check
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ALTracer committed Jan 6, 2025
1 parent 74fd17d commit 9c60b33
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/gdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9c60b33

Please sign in to comment.