summaryrefslogtreecommitdiffstats
path: root/src/bind.c
diff options
context:
space:
mode:
authorJon Simons <jon@jonsimons.org>2014-02-10 18:20:19 -0800
committerAndreas Schneider <asn@cryptomilk.org>2014-03-12 14:16:28 +0100
commit2db45dd547f461bb225ffbbc259d84b61a6ca66c (patch)
tree44453659ee6d14b7c7cd77097455dd952bc7bf50 /src/bind.c
parent87145387aa12b720b52d6bc75b4dd6cd058c868a (diff)
bind: only set bindfd after successful listen
In 'ssh_bind_listen', move setting of 'sshbind->bindfd' to only happen after the listen call: otherwise 'bindfd' can be set to a bogus descriptor for the case that listen fails. Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/bind.c')
-rw-r--r--src/bind.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/bind.c b/src/bind.c
index 03d34031..b929b5c4 100644
--- a/src/bind.c
+++ b/src/bind.c
@@ -254,7 +254,6 @@ int ssh_bind_listen(ssh_bind sshbind) {
sshbind->rsa = NULL;
return -1;
}
- sshbind->bindfd = fd;
if (listen(fd, 10) < 0) {
ssh_set_error(sshbind, SSH_FATAL,
@@ -267,6 +266,8 @@ int ssh_bind_listen(ssh_bind sshbind) {
sshbind->rsa = NULL;
return -1;
}
+
+ sshbind->bindfd = fd;
} else {
SSH_LOG(SSH_LOG_INFO, "Using app-provided bind socket");
}