From 1667d5599dec62aa6836560f01e5c90bad52c6bb Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 8 Jun 2019 23:21:45 +0200 Subject: bindlocal: detect and avoid IP version mismatches in bind() Reported-by: Alex Grebenschikov Fixes #3993 Closes #4002 --- lib/connect.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/connect.c') diff --git a/lib/connect.c b/lib/connect.c index 002535b42..4a1f2c640 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -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 { -- cgit v1.2.3