diff --git a/CHANGES b/CHANGES index 21505bbaad..7fb772747f 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,10 @@ 1352. [bug] dig, host, nslookup when falling back to TCP use the current search entry (if any). [RT #3374] +1351. [bug] lwres_getipnodebyname() returned the wrong name + when given a IPv4 literal, af=AF_INET6 and AI_MAPPED + was set. + 1350. [bug] dns_name_fromtext() failed to handle too many labels gracefully. diff --git a/lib/lwres/getipnode.c b/lib/lwres/getipnode.c index 96f61120c6..f9132d0fd8 100644 --- a/lib/lwres/getipnode.c +++ b/lib/lwres/getipnode.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: getipnode.c,v 1.30 2001/07/18 02:37:08 mayer Exp $ */ +/* $Id: getipnode.c,v 1.30.2.1 2002/08/06 04:18:44 marka Exp $ */ #include @@ -137,13 +137,21 @@ lwres_getipnodebyname(const char *name, int af, int flags, int *error_num) { if (v4 == 1 || v6 == 1) { char *addr_list[2]; char *aliases[1]; + char mappedname[sizeof("::ffff:123.123.123.123")]; union { const char *const_name; char *deconst_name; } u; u.const_name = name; - he.h_name = u.deconst_name; + if (v4 == 1 && af == AF_INET6) { + strcpy(mappedname, "::ffff:"); + inet_ntop(AF_INET, (char *)&in4, + mappedname + sizeof("::ffff:") - 1, + sizeof(mappedname) - sizeof("::ffff:") + 1); + he.h_name = mappedname; + } else + he.h_name = u.deconst_name; he.h_addr_list = addr_list; he.h_addr_list[0] = (v4 == 1) ? (char *)&in4 : (char *)&in6; he.h_addr_list[1] = NULL;