diff --git a/CHANGES b/CHANGES index 0b782062ca..569d86307e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +2207. [port] Some implementations of getaddrinfo() fail to set + ai_canonname correctly. [RT #17061] --- 9.5.0a6 released --- diff --git a/bin/check/check-tool.c b/bin/check/check-tool.c index 8d9f8caef3..3edcfc9f80 100644 --- a/bin/check/check-tool.c +++ b/bin/check/check-tool.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: check-tool.c,v 1.29 2007/06/18 23:47:16 tbox Exp $ */ +/* $Id: check-tool.c,v 1.30 2007/08/06 01:06:49 marka Exp $ */ /*! \file */ @@ -193,7 +193,16 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner, dns_name_format(name, namebuf, sizeof(namebuf) - 1); switch (result) { case 0: - if (strcasecmp(ai->ai_canonname, namebuf) != 0 && + /* + * Work around broken getaddrinfo() implementations that + * fail to set ai_canonname on first entry. + */ + cur = ai; + while (cur != NULL && cur->ai_canonname == NULL && + cur->ai_next != NULL) + cur = cur->ai_next; + if (ai != NULL && cur->ai_canonname != NULL && + strcasecmp(ai->ai_canonname, namebuf) != 0 && !logged(namebuf, ERR_IS_CNAME)) { dns_zone_log(zone, ISC_LOG_ERROR, "%s/NS '%s' (out of zone) " @@ -348,7 +357,7 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner, static isc_boolean_t checkmx(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) { #ifdef USE_GETADDRINFO - struct addrinfo hints, *ai; + struct addrinfo hints, *ai, *cur; char namebuf[DNS_NAME_FORMATSIZE + 1]; char ownerbuf[DNS_NAME_FORMATSIZE]; int result; @@ -373,7 +382,16 @@ checkmx(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) { dns_name_format(name, namebuf, sizeof(namebuf) - 1); switch (result) { case 0: - if (strcasecmp(ai->ai_canonname, namebuf) != 0) { + /* + * Work around broken getaddrinfo() implementations that + * fail to set ai_canonname on first entry. + */ + cur = ai; + while (cur != NULL && cur->ai_canonname == NULL && + cur->ai_next != NULL) + cur = cur->ai_next; + if (cur != NULL && cur->ai_canonname != NULL && + strcasecmp(cur->ai_canonname, namebuf) != 0) { if ((zone_options & DNS_ZONEOPT_WARNMXCNAME) != 0) level = ISC_LOG_WARNING; if ((zone_options & DNS_ZONEOPT_IGNOREMXCNAME) == 0) { @@ -422,7 +440,7 @@ checkmx(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) { static isc_boolean_t checksrv(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) { #ifdef USE_GETADDRINFO - struct addrinfo hints, *ai; + struct addrinfo hints, *ai, *cur; char namebuf[DNS_NAME_FORMATSIZE + 1]; char ownerbuf[DNS_NAME_FORMATSIZE]; int result; @@ -447,7 +465,16 @@ checksrv(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) { dns_name_format(name, namebuf, sizeof(namebuf) - 1); switch (result) { case 0: - if (strcasecmp(ai->ai_canonname, namebuf) != 0) { + /* + * Work around broken getaddrinfo() implementations that + * fail to set ai_canonname on first entry. + */ + cur = ai; + while (cur != NULL && cur->ai_canonname == NULL && + cur->ai_next != NULL) + cur = cur->ai_next; + if (cur != NULL && cur->ai_canonname != NULL && + strcasecmp(cur->ai_canonname, namebuf) != 0) { if ((zone_options & DNS_ZONEOPT_WARNSRVCNAME) != 0) level = ISC_LOG_WARNING; if ((zone_options & DNS_ZONEOPT_IGNORESRVCNAME) == 0) {