Author: Jason Molenda Date: 2020-10-20T01:43:31-07:00 New Revision: c932266c8d0414672974eb777bbbb86f1d0f122d
URL: https://github.com/llvm/llvm-project/commit/c932266c8d0414672974eb777bbbb86f1d0f122d DIFF: https://github.com/llvm/llvm-project/commit/c932266c8d0414672974eb777bbbb86f1d0f122d.diff LOG: Add a nul byte to packet str before logging, increase default size. Add a nul byte to the stream in CommunicationKDP::CheckForPacket before we send the GetData() to a Log::Printf as a c-str. Avoids a crash when logging kdp communications and memory layout isn't in your favor. Added: Modified: lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h Removed: ################################################################################ diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index dc283fce8104..fc0539a089e2 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -238,6 +238,7 @@ bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len, if (log && log->GetVerbose()) { PacketStreamType log_strm; DumpHexBytes(&log_strm, src, src_len, UINT32_MAX, LLDB_INVALID_ADDRESS); + log_strm.PutChar('\0'); LLDB_LOGF(log, "CommunicationKDP::%s adding %u bytes: %s", __FUNCTION__, (uint32_t)src_len, log_strm.GetData()); } diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h index d04765f9d86b..4981b42008db 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h @@ -25,7 +25,7 @@ class CommunicationKDP : public lldb_private::Communication { const static uint32_t kMaxPacketSize = 1200; const static uint32_t kMaxDataSize = 1024; - typedef lldb_private::StreamBuffer<1024> PacketStreamType; + typedef lldb_private::StreamBuffer<4096> PacketStreamType; enum CommandType { KDP_CONNECT = 0u, KDP_DISCONNECT, _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits