Author: Jason Molenda Date: 2020-05-11T20:05:57-07:00 New Revision: 2b8b783b1ab4a2388d5d80136221729871f65a32
URL: https://github.com/llvm/llvm-project/commit/2b8b783b1ab4a2388d5d80136221729871f65a32 DIFF: https://github.com/llvm/llvm-project/commit/2b8b783b1ab4a2388d5d80136221729871f65a32.diff LOG: Quote error string from qLaunchSuccess If the error message from qLaunchSucess included a gdb RSP metacharacter, it could crash lldb. Apply the binary escaping to the string before sending it to lldb; lldb promiscuously applies the binary escaping protocol on packets it receives. Also fix a small bug in cstring_to_asciihex_string where a high bit character (eg utf-8 chars) would not be quoted correctly due to signed char fun. Differential Revision: https://reviews.llvm.org/D79614 rdar://problem/62873581 Added: Modified: lldb/tools/debugserver/source/RNBRemote.cpp Removed: ################################################################################ diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index df358065f877..5f066bda4227 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -1643,7 +1643,9 @@ rnb_err_t RNBRemote::HandlePacket_qLaunchSuccess(const char *p) { return SendPacket("OK"); std::ostringstream ret_str; std::string status_str; - ret_str << "E" << m_ctx.LaunchStatusAsString(status_str); + std::string error_quoted = binary_encode_string + (m_ctx.LaunchStatusAsString(status_str)); + ret_str << "E" << error_quoted; return SendPacket(ret_str.str()); } @@ -2677,8 +2679,9 @@ std::string cstring_to_asciihex_string(const char *str) { std::string hex_str; hex_str.reserve (strlen (str) * 2); while (str && *str) { + uint8_t c = *str++; char hexbuf[5]; - snprintf (hexbuf, sizeof(hexbuf), "%02x", *str++); + snprintf (hexbuf, sizeof(hexbuf), "%02x", c); hex_str += hexbuf; } return hex_str; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits