summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index d19e19802da..1f4d63d482a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -517,18 +517,25 @@ GDBRemoteCommunication::WaitForPacketNoLock (StringExtractorGDBRemote &response,
std::string &response_str = response.GetStringRef();
if (packet_data[0] == '$')
{
- assert (packet_size >= 4); // Must have at least '$#CC' where CC is checksum
- assert (packet_data[packet_size-3] == '#');
- assert (::isxdigit (packet_data[packet_size-2])); // Must be checksum hex byte
- assert (::isxdigit (packet_data[packet_size-1])); // Must be checksum hex byte
- response_str.assign (packet_data + 1, packet_size - 4);
+ bool success = false;
+ if (packet_size < 4)
+ ::fprintf (stderr, "Packet that starts with $ is too short: '%s'\n", packet_data);
+ else if (packet_data[packet_size-3] != '#' ||
+ !::isxdigit (packet_data[packet_size-2]) ||
+ !::isxdigit (packet_data[packet_size-1]))
+ ::fprintf (stderr, "Invalid checksum footer for packet: '%s'\n", packet_data);
+ else
+ success = true;
+
+ if (success)
+ response_str.assign (packet_data + 1, packet_size - 4);
if (m_send_acks)
{
char packet_checksum = strtol (&packet_data[packet_size-2], NULL, 16);
char actual_checksum = CalculcateChecksum (&response_str[0], response_str.size());
checksum_error = packet_checksum != actual_checksum;
// Send the ack or nack if needed
- if (checksum_error)
+ if (checksum_error || !success)
SendAck('-');
else
SendAck('+');
OpenPOWER on IntegriCloud