From da5795a32a5b28fc8afd59e4887e19ec1252d0d0 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 14 Sep 2001 06:31:40 +0000 Subject: [PATCH] 995. [bug] dig, host, nslookup: using a raw IPv6 address as a target address should be fatal on a IPv4 only system. --- bin/dig/dighost.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index a30acc0bd8..ced598a03a 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dighost.c,v 1.224 2001/09/12 00:22:53 gson Exp $ */ +/* $Id: dighost.c,v 1.225 2001/09/14 06:31:40 marka Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -2512,15 +2512,16 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) { debug("get_address()"); - /* - * Assume we have v4 if we don't have v6, since setup_libs - * fatal()'s out if we don't have either. - */ - if (have_ipv6 && inet_pton(AF_INET6, host, &in6) == 1) + if (inet_pton(AF_INET6, host, &in6) == 1) { + if (!have_ipv6) + fatal("Protocol family INET6 not supported '%s'", host); isc_sockaddr_fromin6(sockaddr, &in6, port); - else if (inet_pton(AF_INET, host, &in4) == 1) - isc_sockaddr_fromin(sockaddr, &in4, port); - else { + } else if (inet_pton(AF_INET, host, &in4) == 1) { + if (have_ipv4) + isc_sockaddr_fromin(sockaddr, &in4, port); + else + isc_sockaddr_v6fromin(sockaddr, &in4, port); + } else { #ifdef USE_GETADDRINFO memset(&hints, 0, sizeof(hints)); if (!have_ipv6)