Skip to content

Commit 9bf4a36

Browse files
committed
net_ssh: Clean up properly in off-nominal paths.
* Add missing bbs_pthread_enable_cancel before continuing. * Clean up SSH session if ssh_bind_accept fails.
1 parent 5ac5a1f commit 9bf4a36

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

nets/net_ssh.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,6 +1967,8 @@ static void *ssh_listener(void *unused)
19671967
if (ssh_bind_accept(sshbind, session) == SSH_ERROR) {
19681968
bbs_pthread_disable_cancel();
19691969
bbs_error("%s\n", ssh_get_error(sshbind));
1970+
ssh_disconnect(session);
1971+
ssh_free(session);
19701972
bbs_pthread_enable_cancel();
19711973
continue;
19721974
}
@@ -1975,6 +1977,7 @@ static void *ssh_listener(void *unused)
19751977
if (bbs_pthread_create_detached(&ssh_thread, NULL, ssh_connection, session)) {
19761978
ssh_disconnect(session);
19771979
ssh_free(session);
1980+
bbs_pthread_enable_cancel();
19781981
continue;
19791982
}
19801983
bbs_pthread_enable_cancel();

0 commit comments

Comments
 (0)