rpms/bind/devel bind-9.3.2-bz187286_fix_host_cname.patch,NONE,1.1

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Thu Mar 30 23:36:33 UTC 2006


Author: jvdias

Update of /cvs/dist/rpms/bind/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv23242

Added Files:
	bind-9.3.2-bz187286_fix_host_cname.patch 
Log Message:
fix bug 187286: upstream ISC bug #15702: make host(1) use any cname returned for the A lookup for the AAAA and MX lookups, avoiding redundant "is an alias for" messages

bind-9.3.2-bz187286_fix_host_cname.patch:
 host.c |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 65 insertions(+), 1 deletion(-)

--- NEW FILE bind-9.3.2-bz187286_fix_host_cname.patch ---
--- bind-9.3.2/bin/dig/host.c.bz187286_fix_host_cname	2006-03-29 19:16:03.000000000 -0500
+++ bind-9.3.2/bin/dig/host.c	2006-03-30 17:53:12.000000000 -0500
@@ -37,6 +37,7 @@
 #include <dns/rdataclass.h>
 #include <dns/rdataset.h>
 #include <dns/rdatatype.h>
+#include <dns/rdatastruct.h>
 
 #include <dig/dig.h>
 
@@ -328,6 +329,60 @@
 }
 
 static isc_result_t
+get_cname( dig_query_t *query, dns_message_t *msg, char *cnamestr, int cnamestrlen )
+{
+    /*  check for a cname result in msg answer section; if present, copy it into cnamestr 
+     *  Jason Vas Dias<jvdias at redhat.com>, Red Hat, Inc. fix for bugzilla 187286 (RT #15702)
+     */
+	isc_result_t result;
+	dns_name_t   *aname;
+	dns_rdataset_t *rdataset;
+	dns_rdata_t  rdata = DNS_RDATA_INIT;
+
+	*cnamestr = '\0';
+			
+	result = dns_message_firstname(msg, DNS_SECTION_ANSWER);
+	if (result != ISC_R_SUCCESS)
+	    return ISC_R_FAILURE;
+
+	do
+	{
+		aname = NULL;
+		dns_message_currentname(msg, DNS_SECTION_ANSWER, &aname);
+		if (   aname 
+		    &&(dns_name_equal(query->lookup->name, aname) == ISC_TRUE)
+		   )
+		{
+			for (rdataset = ISC_LIST_HEAD(aname->list);
+			     rdataset != NULL;
+			     rdataset = ISC_LIST_NEXT(rdataset, link)) 
+			{
+				isc_result_t loopresult = dns_rdataset_first(rdataset);
+				while (loopresult == ISC_R_SUCCESS) 
+				{
+					dns_rdataset_current(rdataset, &rdata);
+					if ( rdata.type == dns_rdatatype_cname )
+					{
+						dns_rdata_cname_t cname;
+						if ( dns_rdata_tostruct( &rdata, &cname, NULL ) 
+						     == ISC_R_SUCCESS
+						   )
+						{
+							dns_name_format(&(cname.cname), cnamestr, cnamestrlen );
+							return ( ISC_R_SUCCESS );
+						}
+					}
+					dns_rdata_reset(&rdata);
+					loopresult = dns_rdataset_next(rdataset);
+				}
+			}
+		}
+	} while ( dns_message_nextname(msg, DNS_SECTION_ANSWER) == ISC_R_SUCCESS );
+
+	return ( ISC_R_FAILURE );
+}
+
+static isc_result_t
 printrdata(dns_message_t *msg, dns_rdataset_t *rdataset, dns_name_t *owner,
 	   const char *set_name, isc_boolean_t headers)
 {
@@ -393,7 +448,16 @@
 
 		/* Add AAAA and MX lookups. */
 
-		dns_name_format(query->lookup->name, namestr, sizeof(namestr));
+		if ( ! ISC_LIST_EMPTY( msg->sections[DNS_SECTION_ANSWER] ) )
+		{ 
+			/* check for CNAME answer ; if present, then use canonical name for
+			 * AAAA and MX lookups.
+			 */		
+			if ( get_cname( query, msg, namestr, sizeof(namestr) ) != ISC_R_SUCCESS )
+				dns_name_format(query->lookup->name, namestr, sizeof(namestr));			
+		} else	/* use same name for AAAA and MX lookups */			
+			dns_name_format(query->lookup->name, namestr, sizeof(namestr));
+
 		lookup = clone_lookup(query->lookup, ISC_FALSE);
 		if (lookup != NULL) {
 			strncpy(lookup->textname, namestr,




More information about the fedora-cvs-commits mailing list