From: Daniel Stenberg Date: Fri, 8 Nov 2024 15:31:41 +0000 (+0100) Subject: libssh: when using IPv6 numerical address, add brackets X-Git-Tag: curl-8_11_1~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93c65c00e52c4c8cdc09b2d9194ce63763c7349e;p=thirdparty%2Fcurl.git libssh: when using IPv6 numerical address, add brackets Reported-by: henrikjehgmti on github Fixes #15522 Closes #15524 --- diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 2781365bf4..eeef5ca01d 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;