]> granicus.if.org Git - curl/commitdiff
bindlocal: detect and avoid IP version mismatches in bind()
authorDaniel Stenberg <daniel@haxx.se>
Sat, 8 Jun 2019 21:21:45 +0000 (23:21 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 10 Jun 2019 06:01:50 +0000 (08:01 +0200)
Reported-by: Alex Grebenschikov
Fixes #3993
Closes #4002

lib/connect.c

index 002535b429a5b8a538086aec32b1d0b54152fe82..4a1f2c64060c2512d27c156d8b9e3384cba616ae 100644 (file)
@@ -368,6 +368,11 @@ static CURLcode bindlocal(struct connectdata *conn,
         infof(data, "Name '%s' family %i resolved to '%s' family %i\n",
               dev, af, myhost, h->addr->ai_family);
         Curl_resolv_unlock(data, h);
+        if(af != h->addr->ai_family) {
+          /* bad IP version combo, signal the caller to try another address
+             family if available */
+          return CURLE_UNSUPPORTED_PROTOCOL;
+        }
         done = 1;
       }
       else {