mirror of
https://github.com/curl/curl.git
synced 2026-08-26 16:23:32 +03:00
resolve: make forced IPv4 resolve only use A queries
This protects IPv4-only transfers from undesired bad IPv6-related side effects and make IPv4 transfers in dual-stack libcurl behave the same way as in IPv4 single-stack libcurl. Closes #9540
This commit is contained in:
parent
ae9e713c4e
commit
1902e8fc51
5 changed files with 29 additions and 5 deletions
23
lib/hostip.c
23
lib/hostip.c
|
|
@ -297,6 +297,29 @@ static struct Curl_dns_entry *fetch_addr(struct Curl_easy *data,
|
|||
}
|
||||
}
|
||||
|
||||
/* See if the returned entry matches the required resolve mode */
|
||||
if(dns && data->conn->ip_version != CURL_IPRESOLVE_WHATEVER) {
|
||||
int pf = PF_INET;
|
||||
bool found = false;
|
||||
struct Curl_addrinfo *addr = dns->addr;
|
||||
|
||||
if(data->conn->ip_version == CURL_IPRESOLVE_V6)
|
||||
pf = PF_INET6;
|
||||
|
||||
while(addr) {
|
||||
if(addr->ai_family == pf) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
addr = addr->ai_next;
|
||||
}
|
||||
|
||||
if(!found) {
|
||||
infof(data, "Hostname in DNS cache doesn't have needed family, zapped");
|
||||
dns = NULL; /* the memory deallocation is being handled by the hash */
|
||||
Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1);
|
||||
}
|
||||
}
|
||||
return dns;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue