Bugzilla – Attachment 3108 Details for
Bug 2814
Connection error should report failure instead of success
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
revised diff
bz2814.diff (text/plain), 2.21 KB, created by
Damien Miller
on 2018-01-05 13:27:35 AEDT
(
hide
)
Description:
revised diff
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2018-01-05 13:27:35 AEDT
Size:
2.21 KB
patch
obsolete
>commit 56710e8fbb0503b61e19e31c4a9a3b0752c7f83a >Author: Damien Miller <djm@mindrot.org> >Date: Fri Jan 5 13:28:14 2018 +1100 > > bz2814 > >diff --git a/sshconnect.c b/sshconnect.c >index 4359ed3..a75ff9e 100644 >--- a/sshconnect.c >+++ b/sshconnect.c >@@ -404,7 +404,7 @@ ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, > int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv) > { > int on = 1; >- int sock = -1, attempt; >+ int oerrno, sock = -1, attempt; > char ntop[NI_MAXHOST], strport[NI_MAXSERV]; > struct addrinfo *ai; > >@@ -424,12 +424,16 @@ ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, > */ > for (ai = aitop; ai; ai = ai->ai_next) { > if (ai->ai_family != AF_INET && >- ai->ai_family != AF_INET6) >+ ai->ai_family != AF_INET6) { >+ errno = EAFNOSUPPORT; > continue; >+ } > if (getnameinfo(ai->ai_addr, ai->ai_addrlen, > ntop, sizeof(ntop), strport, sizeof(strport), > NI_NUMERICHOST|NI_NUMERICSERV) != 0) { >+ oerrno = errno; > error("%s: getnameinfo failed", __func__); >+ errno = oerrno; > continue; > } > debug("Connecting to %.200s [%.100s] port %s.", >@@ -439,6 +443,7 @@ ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, > sock = ssh_create_socket(needpriv, ai); > if (sock < 0) > /* Any error is already output */ >+ errno = 0; > continue; > > if (timeout_connect(sock, ai->ai_addr, ai->ai_addrlen, >@@ -447,10 +452,12 @@ ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, > memcpy(hostaddr, ai->ai_addr, ai->ai_addrlen); > break; > } else { >+ oerrno = errno; > debug("connect to address %s port %s: %s", > ntop, strport, strerror(errno)); > close(sock); > sock = -1; >+ errno = oerrno; > } > } > if (sock != -1) >@@ -460,8 +467,8 @@ ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, > /* Return failure if we didn't get a successful connection. */ > if (sock == -1) { > error("ssh: connect to host %s port %s: %s", >- host, strport, strerror(errno)); >- return (-1); >+ host, strport, errno == 0 ? "failure" : strerror(errno)); >+ return -1; > } > > debug("Connection established.");
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
dtucker
:
ok+
Actions:
View
|
Diff
Attachments on
bug 2814
:
3106
| 3108