[Lldb-commits] [lldb] [lldb] Fix lldb-server host and port address parsing (PR #191414)

Georgiy Samoylov via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 13 01:34:54 PDT 2026


================
@@ -300,16 +305,13 @@ Socket::DecodeHostAndPort(llvm::StringRef host_and_port) {
       ret.hostname = ret.hostname.substr(1, ret.hostname.size() - 2);
     if (to_integer(matches[2], ret.port, 10))
       return ret;
-  } else {
-    // If this was unsuccessful, then check if it's simply an unsigned 16-bit
-    // integer, representing a port with an empty host.
----------------
sga-sc wrote:

This code is reachable when `host_and_port` is just a number, as in the second case in PR description. According to lldb-server docs https://github.com/llvm/llvm-project/blob/682ae8b626393ad77afebebda912f14f3c55a003/lldb/docs/man/lldb-server.rst?plain=1#L114

we shouldn't accept such IP-addresses at all, because a colon is required. Previously, lldb-server crashed when this branch was taken: we filled only the `port` field in `ret` while leaving `host` uninitialized, and other functions that expected a valid `host` then failed.

https://github.com/llvm/llvm-project/pull/191414


More information about the lldb-commits mailing list