peer: fix ipv6 detection

When trying to detect ipv6 addresses, ipv4 addresses were also
flagged as ipv6.

Add test2413 to check.

Closes #22134
This commit is contained in:
Stefan Eissing 2026-06-22 14:45:25 +02:00 committed by Daniel Stenberg
parent d824266425
commit be1d976a2a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 141 additions and 2 deletions

View file

@ -222,7 +222,14 @@ static CURLcode peer_parse_host(struct Curl_easy *data,
if(scan_for_ipv6 &&
Curl_looks_like_ipv6(pp->host_user.str, pp->host_user.len, TRUE,
&pp->host, &pp->zoneid)) {
pp->ipv6 = TRUE;
if(pp->host_user.len < MAX_IPADR_LEN) {
char tmp[MAX_IPADR_LEN];
memcpy(tmp, pp->host_user.str, pp->host_user.len);
tmp[pp->host_user.len] = 0;
pp->ipv6 = !Curl_is_ipv4addr(tmp);
}
else
pp->ipv6 = TRUE;
}
else
pp->host = pp->host_user;