]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
753. [bug] dig, host, and nslookup would fail to contact a
authorBrian Wellington <source@isc.org>
Sat, 24 Feb 2001 20:53:26 +0000 (20:53 +0000)
committerBrian Wellington <source@isc.org>
Sat, 24 Feb 2001 20:53:26 +0000 (20:53 +0000)
                        remote server if getaddrinfo() returned an IPv6
                        address on a system that doesn't support IPv6.

CHANGES
bin/dig/dighost.c

diff --git a/CHANGES b/CHANGES
index 98a91693c86f9b054ce1581503e38a95f54f84f2..1208773db61c44452020dea64c96a0c907c4f78b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+ 753.  [bug]           dig, host, and nslookup would fail to contact a
+                       remote server if getaddrinfo() returned an IPv6
+                       address on a system that doesn't support IPv6.
+
  752.  [func]          Correct bad tv_usec elements returned by gettimeofday().
 
  751.  [func]          Log successful zone loads / transfers.
index 81d124739bd06c1eb6a0269bfc94b1d397e49c22..cb4557670d10dcf4d006ca52ff99b3e5608b7724 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dighost.c,v 1.193 2001/02/17 01:05:29 gson Exp $ */
+/* $Id: dighost.c,v 1.194 2001/02/24 20:53:26 bwelling Exp $ */
 
 /*
  * Notice to programmers:  Do not use this code as an example of how to
@@ -2645,7 +2645,7 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) {
        struct in_addr in4;
        struct in6_addr in6;
 #ifdef USE_GETADDRINFO
-       struct addrinfo *res = NULL;
+       struct addrinfo *res = NULL, hints;
        int result;
 #else
        struct hostent *he;
@@ -2663,9 +2663,16 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) {
                isc_sockaddr_fromin(sockaddr, &in4, port);
        else {
 #ifdef USE_GETADDRINFO
+               memset(&hints, 0, sizeof(hints));
+               if (!have_ipv6)
+                       hints.ai_family = PF_INET;
+               else if (!have_ipv4)
+                       hints.ai_family = PF_INET6;
+               else
+                       hints.ai_family = PF_UNSPEC;
                debug ("before getaddrinfo()");
                isc_app_block();
-               result = getaddrinfo(host, NULL, NULL, &res);
+               result = getaddrinfo(host, NULL, &hints, &res);
                isc_app_unblock();
                if (result != 0) {
                        fatal("Couldn't find server '%s': %s",