]> 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)
committerDmitry Belyavskiy <beldmit@gmail.com>
Sat, 10 Jul 2021 15:59:00 +0000 (17:59 +0200)
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: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/16033)

crypto/bio/bio_addr.c

index 0efbc3cb44a948c15ba9dd83747a559b8966cee4..d18c849ade158b41f591b5fe17560d5153c8c117 100644 (file)
@@ -696,7 +696,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