vishalmishra434 / rpms / openssh

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