From: Daiki Ueno Date: Thu, 8 Jul 2021 17:22:36 +0000 (+0200) Subject: BIO_lookup_ex: use AI_ADDRCONFIG only if explicit host name is given X-Git-Tag: OpenSSL_1_1_1l~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=474cd196d628b1f91efa32827b403e2c1d896f81;p=thirdparty%2Fopenssl.git BIO_lookup_ex: use AI_ADDRCONFIG only if explicit host name is given The flag only affects which record types are queried via DNS (A or AAAA, or both). When node is NULL and AF_UNSPEC is used, it prevents getaddrinfo returning the right address associated with the loopback interface. Signed-off-by: Daiki Ueno Reviewed-by: Dmitry Belyavskiy Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/16039) --- diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c index b023bbda406..ea15601f3d5 100644 --- a/crypto/bio/b_addr.c +++ b/crypto/bio/b_addr.c @@ -689,7 +689,7 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type, hints.ai_protocol = protocol; # ifdef AI_ADDRCONFIG # ifdef AF_UNSPEC - if (family == AF_UNSPEC) + if (host != NULL && family == AF_UNSPEC) # endif hints.ai_flags |= AI_ADDRCONFIG; # endif