kentpeacock / rpms / openssh

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