1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-17 06:18:58 +03:00

bind: Set socket connected after accepting connection

Also factor out the operation to the single place. Original patch drafted by
Zekun Ni in the following issue:

https://gitlab.com/libssh/libssh-mirror/-/issues/155

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2022-10-31 16:10:33 +01:00
parent 8f7c179bed
commit 06a0a957c9
3 changed files with 25 additions and 9 deletions

View File

@@ -426,6 +426,7 @@ void ssh_bind_free(ssh_bind sshbind){
int ssh_bind_accept_fd(ssh_bind sshbind, ssh_session session, socket_t fd)
{
ssh_poll_handle handle = NULL;
int i, rc;
if (sshbind == NULL) {
@@ -517,7 +518,12 @@ int ssh_bind_accept_fd(ssh_bind sshbind, ssh_session session, socket_t fd)
return SSH_ERROR;
}
ssh_socket_set_fd(session->socket, fd);
ssh_socket_get_poll_handle(session->socket);
handle = ssh_socket_get_poll_handle(session->socket);
if (handle == NULL) {
ssh_set_error_oom(sshbind);
return SSH_ERROR;
}
ssh_socket_set_connected(session->socket, handle);
/* We must try to import any keys that could be imported in case
* we are not using ssh_bind_listen (which is the other place