summaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorLucas Clemente Vella <lvella@gmail.com>2021-04-24 20:04:53 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-05-20 16:58:31 +0200
commit84d2839740ca78041ac7419d9aaeac55c1e1c729 (patch)
treeaee6202a7815b0cce0e1a2b9179c3b4421e7fb9a /lib/url.c
parentac54b10933749d4c17d9568532ff2f1ed64c119a (diff)
downloadcurl-84d2839740ca78041ac7419d9aaeac55c1e1c729.tar.gz
CURLOPT_IPRESOLVE: preventing wrong IP version from being used
In some situations, it was possible that a transfer was setup to use an specific IP version, but due do DNS caching or connection reuse, it ended up using a different IP version from requested. This commit changes the effect of CURLOPT_IPRESOLVE from simply restricting address resolution to preventing the wrong connection type being used, when choosing a connection from the pool, and to restricting what addresses could be used when establishing a new connection. It is important that all addresses versions are resolved, even if not used in that transfer in particular, because the result is cached, and could be useful for a different transfer with a different CURLOPT_IPRESOLVE setting. Closes #6853
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/url.c b/lib/url.c
index 5f6462617..1ee38af0d 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1172,6 +1172,12 @@ ConnectionExists(struct Curl_easy *data,
continue;
}
+ if(data->set.ipver != CURL_IPRESOLVE_WHATEVER
+ && data->set.ipver != check->ip_version) {
+ /* skip because the connection is not via the requested IP version */
+ continue;
+ }
+
if(bundle->multiuse == BUNDLE_MULTIPLEX)
multiplexed = CONN_INUSE(check);