mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
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>
This commit is contained in:
committed by
Andreas Schneider
parent
e99246246b
commit
5eeac3566e
@@ -254,7 +254,6 @@ int ssh_bind_listen(ssh_bind sshbind) {
|
|||||||
sshbind->rsa = NULL;
|
sshbind->rsa = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sshbind->bindfd = fd;
|
|
||||||
|
|
||||||
if (listen(fd, 10) < 0) {
|
if (listen(fd, 10) < 0) {
|
||||||
ssh_set_error(sshbind, SSH_FATAL,
|
ssh_set_error(sshbind, SSH_FATAL,
|
||||||
@@ -267,6 +266,8 @@ int ssh_bind_listen(ssh_bind sshbind) {
|
|||||||
sshbind->rsa = NULL;
|
sshbind->rsa = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sshbind->bindfd = fd;
|
||||||
} else {
|
} else {
|
||||||
SSH_LOG(SSH_LOG_INFO, "Using app-provided bind socket");
|
SSH_LOG(SSH_LOG_INFO, "Using app-provided bind socket");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user