aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2015-02-16 17:00:05 +0100
committerKamil Dudka <kdudka@redhat.com>2015-02-23 13:31:01 +0100
commit92835ca5d87850ae0c670d66bd73af391b34cdc3 (patch)
tree11d0d2c703d034cf47e3bd652e8749dbcd7ecd6e
parent5d87b1f22ca044e81c75496f913a7eba34992eee (diff)
connect: avoid skipping an IPv4 address
... in case the protocol versions are mixed in a DNS response (IPv6 -> IPv4 -> IPv6). Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1187531#c3
-rw-r--r--lib/connect.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 32888e653..61b180825 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -542,6 +542,7 @@ static CURLcode trynextip(struct connectdata *conn,
int sockindex,
int tempindex)
{
+ const int other = tempindex ^ 1;
CURLcode result = CURLE_COULDNT_CONNECT;
/* First clean up after the failed socket.
@@ -572,8 +573,11 @@ static CURLcode trynextip(struct connectdata *conn,
}
while(ai) {
- while(ai && ai->ai_family != family)
- ai = ai->ai_next;
+ if(conn->tempaddr[other]) {
+ /* we can safely skip addresses of the other protocol family */
+ while(ai && ai->ai_family != family)
+ ai = ai->ai_next;
+ }
if(ai) {
result = singleipconnect(conn, ai, &conn->tempsock[tempindex]);