]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
BIO_lookup_ex: use AI_ADDRCONFIG only if explicit host name is given
authorDaiki Ueno <dueno@redhat.com>
Thu, 8 Jul 2021 17:22:36 +0000 (19:22 +0200)
committerPauli <pauli@openssl.org>
Tue, 13 Jul 2021 01:28:04 +0000 (11:28 +1000)
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 <dueno@redhat.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16039)

crypto/bio/b_addr.c

index b023bbda406b0fd9982159047128352b1259939e..ea15601f3d51e287e638a65d1693cb12f004a8b8 100644 (file)
@@ -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