kentpeacock / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
aedd00
diff --git a/channels.c b/channels.c
aedd00
--- a/channels.c
aedd00
+++ b/channels.c
aedd00
@@ -3933,16 +3933,26 @@ x11_create_display_inet(int x11_display_
aedd00
 			if (ai->ai_family == AF_INET6)
aedd00
 				sock_set_v6only(sock);
aedd00
 			if (x11_use_localhost)
aedd00
 				set_reuseaddr(sock);
aedd00
 			if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
aedd00
 				debug2("%s: bind port %d: %.100s", __func__,
aedd00
 				    port, strerror(errno));
aedd00
 				close(sock);
aedd00
+
aedd00
+				/* do not remove successfully opened
aedd00
+				 * sockets if the request failed because
aedd00
+				 * the protocol IPv4/6 is not available
aedd00
+				 * (e.g. IPv6 may be disabled while being
aedd00
+				 * supported)
aedd00
+				 */
aedd00
+				if (EADDRNOTAVAIL == errno)
aedd00
+    					continue;
aedd00
+
aedd00
 				for (n = 0; n < num_socks; n++)
aedd00
 					close(socks[n]);
aedd00
 				num_socks = 0;
aedd00
 				break;
aedd00
 			}
aedd00
 			socks[num_socks++] = sock;
aedd00
 			if (num_socks == NUM_SOCKS)
aedd00
 				break;