Skip to content
Snippets Groups Projects
Commit f11d5419 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Catch when cryptFlushData() says the channel is closed.

Also, fix an unlikely race condition.  This, combined with the
cryptlib patches, fixes various weird SSH hangs resulting from
partial reads of the SSH packet headers... a rare event that's
very hard to trigger.  Special thanks to MeaTLoTioN for reporting
this, and running a BBS that manages to trigger it reliably.

Check out The Quantum Wormhole and say thanks!
parent 10b6be34
Branches
Tags
1 merge request!455Update branch with changes from master
......@@ -58,10 +58,10 @@ init_crypt(void)
cryptlib_error_message(status, "initializing cryptlib");
}
static void
static int
FlushData(CRYPT_SESSION sess)
{
(void)cryptFlushData(sess);
return cryptFlushData(sess);
}
void
......@@ -175,7 +175,10 @@ ssh_input_thread(void *args)
conn_api.input_thread_running = 1;
while (ssh_active && !conn_api.terminate) {
pthread_mutex_lock(&ssh_mutex);
FlushData(ssh_session);
if (FlushData(ssh_session) == CRYPT_ERROR_COMPLETE) {
pthread_mutex_unlock(&ssh_mutex);
break;
}
if (ssh_channel != -1) {
if (!check_channel_open(&ssh_channel))
ssh_channel = -1;
......@@ -200,7 +203,10 @@ ssh_input_thread(void *args)
continue;
pthread_mutex_lock(&ssh_mutex);
FlushData(ssh_session);
if (FlushData(ssh_session) == CRYPT_ERROR_COMPLETE) {
pthread_mutex_unlock(&ssh_mutex);
break;
}
// Check channels are active...
if (ssh_channel != -1) {
......@@ -215,6 +221,7 @@ ssh_input_thread(void *args)
pthread_mutex_unlock(&ssh_mutex);
sftpc_finish(oldstate);
oldstate = NULL;
pthread_mutex_lock(&ssh_mutex);
}
}
if (ssh_channel == -1 && sftp_channel == -1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment