From 19455ef7e4640426fd304f0f0eb2f7104ccad0ad Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Mon, 22 Sep 2014 16:21:25 +0000 Subject: 3561691 gethost never returns an ipv6 address Approved by: glebius (mentor) Obtained from: ipfilter CVS repo (r1.34), netbsd CVS repo (r1.4) --- contrib/ipfilter/tools/ipnat_y.y | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'contrib/ipfilter') diff --git a/contrib/ipfilter/tools/ipnat_y.y b/contrib/ipfilter/tools/ipnat_y.y index 71fb8ee37106..b8d22f979e88 100644 --- a/contrib/ipfilter/tools/ipnat_y.y +++ b/contrib/ipfilter/tools/ipnat_y.y @@ -1164,17 +1164,19 @@ hexnumber: hostname: YY_STR { i6addr_t addr; + int family; +#ifdef USE_INET6 + if (nat->in_v[0] == 6) + family = AF_INET6; + else +#endif + family = AF_INET; bzero(&$$, sizeof($$)); - if (gethost(AF_INET, $1, - &addr) == 0) { - $$.a = addr; - $$.f = AF_INET; - } else - if (gethost(AF_INET6, $1, + $$.f = family; + if (gethost(family, $1, &addr) == 0) { $$.a = addr; - $$.f = AF_INET6; } else { FPRINTF(stderr, "Unknown host '%s'\n", -- cgit v1.2.3