From c9a419e44bb65581384f6a2e40a5ecf2bf5d883d Mon Sep 17 00:00:00 2001 From: Stoyan Shopov Date: Thu, 3 Dec 2020 21:03:57 +0200 Subject: [PATCH] Correct loss of sync protocol error #787 --- src/gdb_packet.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gdb_packet.c b/src/gdb_packet.c index f6e79463..6f31e138 100644 --- a/src/gdb_packet.c +++ b/src/gdb_packet.c @@ -81,6 +81,12 @@ int gdb_getpacket(char *packet, int size) break; } } + /* Reset the packet buffer start character to zero, because function + * 'remotePacketProcess()' above overwrites this buffer, and + * an arbitrary character may have been placed there. If this is a '$' + * character, this will cause this loop to be terminated, which is wrong. + */ + packet[0] = 0; } #endif } while (packet[0] != '$');