summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/ssh/sshconnect.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c
index cfc492f5337..8ae6a70be2b 100644
--- a/usr.bin/ssh/sshconnect.c
+++ b/usr.bin/ssh/sshconnect.c
@@ -13,7 +13,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.141 2003/05/15 14:55:25 djm Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.142 2003/05/23 08:29:30 djm Exp $");
#include <openssl/bn.h>
@@ -221,7 +221,7 @@ timeout_connect(int sockfd, const struct sockaddr *serv_addr,
fd_set *fdset;
struct timeval tv;
socklen_t optlen;
- int fdsetsz, optval, rc;
+ int fdsetsz, optval, rc, result = -1;
if (timeout <= 0)
return (connect(sockfd, serv_addr, addrlen));
@@ -253,11 +253,11 @@ timeout_connect(int sockfd, const struct sockaddr *serv_addr,
case 0:
/* Timed out */
errno = ETIMEDOUT;
- return (-1);
+ break;
case -1:
/* Select error */
debug("select: %s", strerror(errno));
- return (-1);
+ break;
case 1:
/* Completed or failed */
optval = 0;
@@ -265,18 +265,20 @@ timeout_connect(int sockfd, const struct sockaddr *serv_addr,
if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &optval,
&optlen) == -1)
debug("getsockopt: %s", strerror(errno));
- return (-1);
+ break;
if (optval != 0) {
errno = optval;
- return (-1);
+ break;
}
+ result = 0;
break;
default:
/* Should not occur */
fatal("Bogus return (%d) from select()", rc);
}
- return (0);
+ xfree(fdset);
+ return (result);
}
/*