libssh: when using IPv6 numerical address, add brackets

Reported-by: henrikjehgmti on github
Fixes #15522
Closes #15524
This commit is contained in:
Daniel Stenberg 2024-11-08 16:31:41 +01:00
parent 9416e49ceb
commit 93c65c00e5
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -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;