1351. [bug] lwres_getipnodebyname() returned the wrong name

when given a IPv4 literal, af=AF_INET6 and AI_MAPPED
                        was set.
This commit is contained in:
Mark Andrews 2002-08-06 04:18:44 +00:00
parent 73d6af8f6a
commit bef1bfc2fa
2 changed files with 14 additions and 2 deletions

View file

@ -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.

View file

@ -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 <config.h>
@ -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;