{"record":{"id":"469a7f5090ab4455","repo":"NationalSecurityAgency/ghidra","slug":"address-must-be-in-the-form-host-port-469a7f","errorCode":null,"errorMessage":"Address must be in the form 'host:port'","messagePattern":"Address must be in the form 'host:port'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-jpda/src/main/java/ghidra/dbg/jdi/rmi/jpda/JdiCommands.java","lineNumber":138,"sourceCode":"\n\tprivate JdiConnector connector;\n\tprivate JdiManagerImpl jdi;\n\n\tpublic State state;\n\tprivate String[] regNames = { \"PC\", \"return_address\" };\n\tpublic long MAX_REFS = 100;\n\n\tpublic JdiCommands(JdiConnector connector) {\n\t\tthis.connector = connector;\n\t\tthis.jdi = connector.getJdi();\n\t\tstate = new State();\n\t}\n\n\tpublic void ghidraTraceConnect(String address) {\n\t\tstate.requireNoClient();\n\t\tString[] addr = address.split(\":\");\n\t\tif (addr.length != 2) {\n\t\t\tthrow new RuntimeException(\"Address must be in the form 'host:port'\");\n\t\t}\n\t\ttry {\n\t\t\tSocketChannel channel =\n\t\t\t\tSocketChannel.open(new InetSocketAddress(addr[0], Integer.parseInt(addr[1])));\n\t\t\tstate.client = new RmiClient(channel, \"jdi\");\n\t\t\tstate.client.setRegistry(connector.remoteMethodRegistry);\n\t\t\tstate.client.negotiate(\"Connect\");\n\t\t\tMsg.out(\"Connected to \" + state.client.getDescription());\n\t\t}\n\t\tcatch (NumberFormatException e) {\n\t\t\tthrow new RuntimeException(\"Port must be numeric\");\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new RuntimeException(\"Error connecting to \" + address + \": \" + e);\n\t\t}\n\t}\n\n\tpublic void ghidraTraceListen(String address) {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-jpda/src/main/java/ghidra/dbg/jdi/rmi/jpda/JdiCommands.java#L120-L156","documentation":"Thrown by ghidraTraceConnect(String address) when the supplied address string does not split into exactly two colon-separated parts. The method naively splits on ':' and requires host and port; this means any address missing the port, missing the host, containing extra colons, or using IPv6 syntax (which itself contains colons) will be rejected before any socket is opened.","triggerScenarios":"Calling ghidraTraceConnect(\"localhost\") (no port), ghidraTraceConnect(\":8080\") (no host), ghidraTraceConnect(\"a:b:c\") (extra colons), or any IPv6 address like \"::1:8080\" which splits into more than two parts.","commonSituations":"User omits the port assuming a default; copy-pasting an IPv6 loopback address; a launch configuration passes a bare hostname; the address string was constructed programmatically without enforcing the host:port contract.","solutions":["Provide the address in strict 'host:port' form, e.g. '127.0.0.1:12345'.","If targeting IPv6, note this parser does not support bracketed notation — connect via an IPv4 address or a hostname that resolves to one.","Validate the address string before calling ghidraTraceConnect: ensure it contains exactly one ':' and both halves are non-empty."],"exampleFix":"// before\nghidraTraceConnect(\"localhost\"); // throws\n\n// after\nghidraTraceConnect(\"127.0.0.1:12345\");","handlingStrategy":"validation","validationCode":"void connectSafe(String address) {\n    String[] parts = address.split(\":\");\n    if (parts.length != 2 || parts[0].isEmpty() || parts[1].isEmpty()) {\n        throw new IllegalArgumentException(\"Address must be 'host:port'\");\n    }\n    ghidraTraceConnect(address);\n}","typeGuard":null,"tryCatchPattern":"try { ghidraTraceConnect(address); }\ncatch (RuntimeException e) {\n    if (e.getMessage().contains(\"host:port\")) { /* re-prompt user for address */ }\n    else throw e;\n}","preventionTips":["Pre-validate address strings with a host:port regex before passing to ghidraTraceConnect.","Avoid IPv6 literals with this API; resolve to IPv4 first.","Centralize address construction so the format contract is enforced in one place."],"tags":["network","address-validation","jdi","ghidra-debug"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}