Use AI_ADDRCONFIG hint with getaddrinfo if available.
authorTomas Mraz <tmraz@fedoraproject.org>
Thu, 21 Mar 2019 12:17:29 +0000 (13:17 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 3 Apr 2019 20:56:54 +0000 (22:56 +0200)
This prevents failure of openssl s_server socket binding to wildcard
address on hosts with disabled IPv6.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8550)

crypto/bio/b_addr.c

index 4be74e4e76a78ba9125c8a64df276a935066763c..0f398243a82273bf84a6bdfe7198704677cb8be8 100644 (file)
@@ -683,6 +683,12 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
         hints.ai_family = family;
         hints.ai_socktype = socktype;
         hints.ai_protocol = protocol;
+#ifdef AI_ADDRCONFIG
+#ifdef AF_UNSPEC
+        if (family == AF_UNSPEC)
+#endif
+            hints.ai_flags |= AI_ADDRCONFIG;
+#endif
 
         if (lookup_type == BIO_LOOKUP_SERVER)
             hints.ai_flags |= AI_PASSIVE;