1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

Check return code of connect(2).

Signed-off-by: William Orr <will@worrbase.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
William Orr
2014-09-14 02:32:24 -07:00
committed by Andreas Schneider
parent 9dc932c02b
commit 250f506487

View File

@@ -382,7 +382,15 @@ socket_t ssh_connect_host_nonblocking(ssh_session session, const char *host,
continue;
}
connect(s, itr->ai_addr, itr->ai_addrlen);
rc = connect(s, itr->ai_addr, itr->ai_addrlen);
if (rc == -1) {
ssh_set_error(session, SSH_FATAL,
"Failed to connect: %s", strerror(errno));
ssh_connect_socket_close(s);
s = -1;
continue;
}
break;
}