components/openssh/patches/034-getaddrinfo_with_ai_addrconfig.patch
author Ivo Raisr <ivo.raisr@oracle.com>
Thu, 29 Oct 2015 13:35:51 -0700
changeset 5035 1d0e6cf38844
child 6930 31ef2580c45d
permissions -rw-r--r--
21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5035
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
     1
#
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
     2
# Use AI_ADDRCONFIG flag for getaddrinfo() hints where
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
     3
# the address family is AF_UNSPEC. See description of AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
     4
# in getaddrinfo(3C).
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
     5
# 
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
     6
# We have contributed back this fix to the OpenSSH upstream community. For
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
     7
# more information, see https://bugzilla.mindrot.org/show_bug.cgi?id=2483
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
     8
# In the future, if this fix is accepted by the upsteam in a later release, we
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
     9
# will remove this patch when we upgrade to that release.
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    10
#
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    11
--- a/canohost.c	Sun Oct 25 20:11:35 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    12
+++ b/canohost.c	Sun Oct 25 20:11:57 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    13
@@ -113,6 +113,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    14
 	memset(&hints, 0, sizeof(hints));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    15
 	hints.ai_family = from.ss_family;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    16
 	hints.ai_socktype = SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    17
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    18
+	if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    19
+		hints.ai_flags = AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    20
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    21
 	if (getaddrinfo(name, NULL, &hints, &aitop) != 0) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    22
 		logit("reverse mapping checking getaddrinfo for %.700s "
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    23
 		    "[%s] failed - POSSIBLE BREAK-IN ATTEMPT!", name, ntop);
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    24
--- a/channels.c	Sun Oct 25 19:30:33 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    25
+++ b/channels.c	Sun Oct 25 19:54:36 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    26
@@ -2853,8 +2853,12 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    27
 	 */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    28
 	memset(&hints, 0, sizeof(hints));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    29
 	hints.ai_family = IPv4or6;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    30
-	hints.ai_flags = wildcard ? AI_PASSIVE : 0;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    31
 	hints.ai_socktype = SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    32
+	hints.ai_flags = wildcard ? AI_PASSIVE : 0;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    33
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    34
+	if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    35
+		hints.ai_flags |= AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    36
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    37
 	snprintf(strport, sizeof strport, "%d", fwd->listen_port);
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    38
 	if ((r = getaddrinfo(addr, strport, &hints, &aitop)) != 0) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    39
 		if (addr == NULL) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    40
@@ -3736,6 +3740,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    41
 		memset(&hints, 0, sizeof(hints));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    42
 		hints.ai_family = IPv4or6;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    43
 		hints.ai_socktype = SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    44
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    45
+		if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    46
+			hints.ai_flags = AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    47
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    48
 		snprintf(strport, sizeof strport, "%d", port);
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    49
 		if ((gaierr = getaddrinfo(name, strport, &hints, &cctx.aitop)) != 0) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    50
 			error("connect_to %.100s: unknown host (%s)", name,
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    51
@@ -3908,8 +3916,12 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    52
 		port = 6000 + display_number;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    53
 		memset(&hints, 0, sizeof(hints));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    54
 		hints.ai_family = IPv4or6;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    55
-		hints.ai_flags = x11_use_localhost ? 0: AI_PASSIVE;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    56
 		hints.ai_socktype = SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    57
+		hints.ai_flags = x11_use_localhost ? 0: AI_PASSIVE;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    58
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    59
+		if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    60
+			hints.ai_flags |= AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    61
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    62
 		snprintf(strport, sizeof strport, "%d", port);
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    63
 		if ((gaierr = getaddrinfo(NULL, strport, &hints, &aitop)) != 0) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    64
 			error("getaddrinfo: %.100s", ssh_gai_strerror(gaierr));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    65
@@ -4090,6 +4102,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    66
 	memset(&hints, 0, sizeof(hints));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    67
 	hints.ai_family = IPv4or6;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    68
 	hints.ai_socktype = SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    69
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    70
+	if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    71
+		hints.ai_flags = AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    72
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    73
 	snprintf(strport, sizeof strport, "%u", 6000 + display_number);
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    74
 	if ((gaierr = getaddrinfo(buf, strport, &hints, &aitop)) != 0) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    75
 		error("%.100s: unknown host. (%s)", buf,
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    76
--- a/servconf.c	Sun Oct 25 19:39:38 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    77
+++ b/servconf.c	Sun Oct 25 19:45:16 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    78
@@ -722,6 +722,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    79
 	hints.ai_family = options->address_family;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    80
 	hints.ai_socktype = SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    81
 	hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    82
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    83
+	if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    84
+		hints.ai_flags |= AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    85
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    86
 	snprintf(strport, sizeof strport, "%d", port);
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    87
 	if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    88
 		fatal("bad addr or host: %s (%s)",
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    89
--- a/ssh-keyscan.c	Sun Oct 25 19:46:28 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    90
+++ b/ssh-keyscan.c	Sun Oct 25 19:54:55 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    91
@@ -326,6 +326,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    92
 	memset(&hints, 0, sizeof(hints));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    93
 	hints.ai_family = IPv4or6;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    94
 	hints.ai_socktype = SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    95
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    96
+	if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    97
+		hints.ai_flags = AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    98
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
    99
 	if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   100
 		error("getaddrinfo %s: %s", host, ssh_gai_strerror(gaierr));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   101
 		return -1;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   102
--- a/ssh.c	Sun Oct 25 19:49:46 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   103
+++ b/ssh.c	Sun Oct 25 19:55:15 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   104
@@ -259,6 +259,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   105
 	hints.ai_socktype = SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   106
 	if (cname != NULL)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   107
 		hints.ai_flags = AI_CANONNAME;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   108
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   109
+	if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   110
+		hints.ai_flags |= AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   111
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   112
 	if ((gaierr = getaddrinfo(name, strport, &hints, &res)) != 0) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   113
 		if (logerr || (gaierr != EAI_NONAME && gaierr != EAI_NODATA))
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   114
 			loglevel = SYSLOG_LEVEL_ERROR;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   115
@@ -298,6 +302,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   116
 	    AF_UNSPEC : options.address_family;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   117
 	hints.ai_socktype = SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   118
 	hints.ai_flags = AI_NUMERICHOST|AI_NUMERICSERV;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   119
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   120
+	if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   121
+		hints.ai_flags |= AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   122
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   123
 	if ((gaierr = getaddrinfo(name, strport, &hints, &res)) != 0) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   124
 		debug2("%s: could not resolve name %.100s as address: %s",
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   125
 		    __func__, name, ssh_gai_strerror(gaierr));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   126
--- a/sshconnect.c	Sun Oct 25 19:57:46 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   127
+++ b/sshconnect.c	Sun Oct 25 19:58:19 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   128
@@ -292,6 +292,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   129
 		hints.ai_socktype = ai->ai_socktype;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   130
 		hints.ai_protocol = ai->ai_protocol;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   131
 		hints.ai_flags = AI_PASSIVE;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   132
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   133
+		if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   134
+			hints.ai_flags |= AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   135
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   136
 		gaierr = getaddrinfo(options.bind_address, NULL, &hints, &res);
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   137
 		if (gaierr) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   138
 			error("getaddrinfo: %s: %s", options.bind_address,
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   139
--- a/regress/netcat.c	Sun Oct 25 19:59:44 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   140
+++ b/regress/netcat.c	Sun Oct 25 20:07:05 2015
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   141
@@ -371,6 +371,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   142
 		hints.ai_protocol = uflag ? IPPROTO_UDP : IPPROTO_TCP;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   143
 		if (nflag)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   144
 			hints.ai_flags |= AI_NUMERICHOST;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   145
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   146
+		if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   147
+			hints.ai_flags |= AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   148
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   149
 	}
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   150
 
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   151
 	if (xflag) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   152
@@ -399,6 +403,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   153
 		proxyhints.ai_protocol = IPPROTO_TCP;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   154
 		if (nflag)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   155
 			proxyhints.ai_flags |= AI_NUMERICHOST;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   156
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   157
+		if (proxyhints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   158
+			proxyhints.ai_flags |= AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   159
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   160
 	}
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   161
 
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   162
 	if (lflag) {
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   163
@@ -673,6 +681,10 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   164
 			ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   165
 			ahints.ai_protocol = uflag ? IPPROTO_UDP : IPPROTO_TCP;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   166
 			ahints.ai_flags = AI_PASSIVE;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   167
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   168
+			if (ahints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   169
+				ahints.ai_flags |= AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   170
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   171
 			if ((error = getaddrinfo(sflag, pflag, &ahints, &ares)))
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   172
 				errx(1, "getaddrinfo: %s", gai_strerror(error));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   173
 
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   174
@@ -1422,8 +1434,12 @@
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   175
 
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   176
 	bzero(&hints, sizeof(hints));
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   177
 	hints.ai_family = v4only ? PF_INET : PF_UNSPEC;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   178
-	hints.ai_flags = numeric ? AI_NUMERICHOST : 0;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   179
 	hints.ai_socktype = SOCK_STREAM;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   180
+	hints.ai_flags = numeric ? AI_NUMERICHOST : 0;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   181
+#ifdef AI_ADDRCONFIG
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   182
+	if (hints.ai_family == AF_UNSPEC)
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   183
+		hints.ai_flags |= AI_ADDRCONFIG;
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   184
+#endif /* AI_ADDRCONFIG */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   185
 	r = getaddrinfo(h, p, &hints, &res);
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   186
 	/* Don't fatal when attempting to convert a numeric address */
1d0e6cf38844 21643415 OpenSSH should use AI_ADDRCONFIG per bug 19827438
Ivo Raisr <ivo.raisr@oracle.com>
parents:
diff changeset
   187
 	if (r != 0) {