From e4955aa46a5a37ccaaab869ce85f367b843dd2a9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 8 Nov 2024 16:31:41 +0100 Subject: [PATCH] [PATCH] libssh: when using IPv6 numerical address, add brackets Reported-by: henrikjehgmti on github Fixes #15522 Closes #15524 Gbp-Pq: Name libssh_when_using_IPv6_numerical_address_add_brackets.patch --- lib/vssh/libssh.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 2781365b..eeef5ca0 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -2191,7 +2191,14 @@ static CURLcode myssh_connect(struct Curl_easy *data, bool *done) return CURLE_FAILED_INIT; } - rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, conn->host.name); + if(conn->bits.ipv6_ip) { + char ipv6[MAX_IPADR_LEN]; + msnprintf(ipv6, sizeof(ipv6), "[%s]", conn->host.name); + rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, ipv6); + } + else + rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, conn->host.name); + if(rc != SSH_OK) { failf(data, "Could not set remote host"); return CURLE_FAILED_INIT; -- 2.30.2