Blame SOURCES/sendmail-8.14.7-ipv6-mx-cname-fix.patch

0da65e
--- sendmail-8.14.7/sendmail/conf.c.orig	2015-12-30 14:24:10.000000000 -0800
0da65e
+++ sendmail-8.14.7/sendmail/conf.c	2015-12-30 14:30:32.000000000 -0800
0da65e
@@ -4234,7 +4234,18 @@ 
0da65e
 	h = gethostbyname(name);
0da65e
 	if (!resv6)
0da65e
 		_res.options &= ~RES_USE_INET6;
0da65e
-	*err = h_errno;
0da65e
+
0da65e
+	/* the function is supposed to return only the requested family */
0da65e
+	if (h != NULL && h->h_addrtype != family)
0da65e
+	{
0da65e
+#  if NETINET6
0da65e
+		freehostent(h);
0da65e
+#  endif /* NETINET6 */
0da65e
+		h = NULL;
0da65e
+		*err = NO_DATA;
0da65e
+	}
0da65e
+	else
0da65e
+		*err = h_errno;
0da65e
 	return h;
0da65e
 }
0da65e
 
0da65e
@@ -4363,6 +4374,17 @@ 
0da65e
 		}
0da65e
 	}
0da65e
 #endif /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */
0da65e
+
0da65e
+	/* the function is supposed to return only the requested family */
0da65e
+	if (h != NULL && h->h_addrtype != family)
0da65e
+	{
0da65e
+# if NETINET6
0da65e
+		freehostent(h);
0da65e
+# endif /* NETINET6 */
0da65e
+		h = NULL;
0da65e
+		SM_SET_H_ERRNO(NO_DATA);
0da65e
+	}
0da65e
+
0da65e
 	if (tTd(61, 10))
0da65e
 	{
0da65e
 		if (h == NULL)
0da65e
@@ -4372,13 +4394,12 @@ 
0da65e
 			sm_dprintf("%s\n", h->h_name);
0da65e
 			if (tTd(61, 11))
0da65e
 			{
0da65e
+				struct in_addr ia;
0da65e
+				size_t i;
0da65e
 #if NETINET6
0da65e
 				struct in6_addr ia6;
0da65e
 				char buf6[INET6_ADDRSTRLEN];
0da65e
-#else /* NETINET6 */
0da65e
-				struct in_addr ia;
0da65e
 #endif /* NETINET6 */
0da65e
-				size_t i;
0da65e
 
0da65e
 				if (h->h_aliases != NULL)
0da65e
 					for (i = 0; h->h_aliases[i] != NULL;
0da65e
@@ -4389,16 +4410,23 @@ 
0da65e
 				{
0da65e
 					char *addr;
0da65e
 
0da65e
+					addr = NULL;
0da65e
 #if NETINET6
0da65e
-					memmove(&ia6, h->h_addr_list[i],
0da65e
-						IN6ADDRSZ);
0da65e
-					addr = anynet_ntop(&ia6,
0da65e
-							   buf6, sizeof(buf6));
0da65e
-#else /* NETINET6 */
0da65e
-					memmove(&ia, h->h_addr_list[i],
0da65e
-						INADDRSZ);
0da65e
-					addr = (char *) inet_ntoa(ia);
0da65e
+					if (h->h_addrtype == AF_INET6)
0da65e
+					{
0da65e
+						memmove(&ia6, h->h_addr_list[i],
0da65e
+							IN6ADDRSZ);
0da65e
+						addr = anynet_ntop(&ia6,
0da65e
+							buf6, sizeof(buf6));
0da65e
+					}
0da65e
+					else
0da65e
 #endif /* NETINET6 */
0da65e
+					/* "else" in #if code above */
0da65e
+					{
0da65e
+						memmove(&ia, h->h_addr_list[i],
0da65e
+							INADDRSZ);
0da65e
+						addr = (char *) inet_ntoa(ia);
0da65e
+					}
0da65e
 					if (addr != NULL)
0da65e
 						sm_dprintf("\taddr: %s\n", addr);
0da65e
 				}