summaryrefslogtreecommitdiff
path: root/mail/sendmail/patches/patch-af
blob: 5f1ea169b17b28890f67e75ff7cda4122d60a168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
$NetBSD: patch-af,v 1.13 2021/07/04 07:57:13 jnemeth Exp $

--- sendmail/conf.c.orig	2020-06-04 06:27:49.000000000 +0000
+++ sendmail/conf.c
@@ -47,6 +47,10 @@ SM_RCSID("@(#)$Id: conf.c,v 8.1192 2014-
 # include "tls.h"
 #endif
 
+#if !HAS_GETHOSTBYNAME2
+extern struct __res_state sm_res;
+#endif
+
 static void	setupmaps __P((void));
 static void	setupmailers __P((void));
 static void	setupqueues __P((void));
@@ -4312,15 +4316,15 @@ sm_getipnodebyname(name, family, flags, 
 	if (family == AF_INET6)
 	{
 		/* From RFC2133, section 6.1 */
-		resv6 = bitset(RES_USE_INET6, _res.options);
-		_res.options |= RES_USE_INET6;
+		resv6 = bitset(RES_USE_INET6, sm_res.options);
+		sm_res.options |= RES_USE_INET6;
 	}
 #  endif /* RES_USE_INET6 */
 	SM_SET_H_ERRNO(0);
 	h = gethostbyname(name);
 #  ifdef RES_USE_INET6
 	if (!resv6)
-		_res.options &= ~RES_USE_INET6;
+		sm_res.options &= ~RES_USE_INET6;
 #  endif
 
 	/* the function is supposed to return only the requested family */
@@ -4536,7 +4540,8 @@ sm_gethostbyaddr(addr, len, type)
 
 #if NETINET6
 	if (type == AF_INET6 &&
-	    IN6_IS_ADDR_UNSPECIFIED((struct in6_addr *) addr))
+	    (IN6_IS_ADDR_UNSPECIFIED((struct in6_addr *) addr) ||
+	    IN6_IS_ADDR_LINKLOCAL((struct in6_addr *) addr)))
 	{
 		/* Avoid reverse lookup for IPv6 unspecified address */
 		SM_SET_H_ERRNO(HOST_NOT_FOUND);
@@ -5690,13 +5695,13 @@ local_hostname_length(hostname)
 {
 	size_t len_host, len_domain;
 
-	if (!*_res.defdname)
+	if (!*sm_res.defdname)
 		res_init();
 	len_host = strlen(hostname);
-	len_domain = strlen(_res.defdname);
+	len_domain = strlen(sm_res.defdname);
 	if (len_host > len_domain &&
 	    (sm_strcasecmp(hostname + len_host - len_domain,
-			_res.defdname) == 0) &&
+			sm_res.defdname) == 0) &&
 	    hostname[len_host - len_domain - 1] == '.')
 		return len_host - len_domain - 1;
 	else