1
1
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Этот коммит содержится в:
Jakub Jelen 2020-04-09 12:10:53 +02:00
родитель 58d53f1397
Коммит 945829a5dd

Просмотреть файл

@ -550,34 +550,37 @@ int ssh_bind_accept_fd(ssh_bind sshbind, ssh_session session, socket_t fd){
return SSH_OK;
}
int ssh_bind_accept(ssh_bind sshbind, ssh_session session) {
socket_t fd = SSH_INVALID_SOCKET;
int rc;
if (sshbind->bindfd == SSH_INVALID_SOCKET) {
ssh_set_error(sshbind, SSH_FATAL,
"Can't accept new clients on a not bound socket.");
return SSH_ERROR;
}
int ssh_bind_accept(ssh_bind sshbind, ssh_session session)
{
socket_t fd = SSH_INVALID_SOCKET;
int rc;
if (session == NULL){
ssh_set_error(sshbind, SSH_FATAL,"session is null");
return SSH_ERROR;
}
if (sshbind->bindfd == SSH_INVALID_SOCKET) {
ssh_set_error(sshbind, SSH_FATAL,
"Can't accept new clients on a not bound socket.");
return SSH_ERROR;
}
fd = accept(sshbind->bindfd, NULL, NULL);
if (fd == SSH_INVALID_SOCKET) {
ssh_set_error(sshbind, SSH_FATAL,
"Accepting a new connection: %s",
strerror(errno));
return SSH_ERROR;
}
rc = ssh_bind_accept_fd(sshbind, session, fd);
if (session == NULL) {
ssh_set_error(sshbind, SSH_FATAL, "session is null");
return SSH_ERROR;
}
if(rc == SSH_ERROR){
CLOSE_SOCKET(fd);
ssh_socket_free(session->socket);
}
return rc;
fd = accept(sshbind->bindfd, NULL, NULL);
if (fd == SSH_INVALID_SOCKET) {
ssh_set_error(sshbind, SSH_FATAL,
"Accepting a new connection: %s",
strerror(errno));
return SSH_ERROR;
}
rc = ssh_bind_accept_fd(sshbind, session, fd);
if (rc == SSH_ERROR) {
CLOSE_SOCKET(fd);
ssh_socket_free(session->socket);
}
return rc;
}