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

Expand ssh_mutex over the flushes.

This should also resolve a conspiracy Coverity has about two input
threads running at the same time.
parent 67a9bb19
No related branches found
No related tags found
No related merge requests found
Pipeline #5868 passed
...@@ -228,17 +228,16 @@ ssh_input_thread(void *args) ...@@ -228,17 +228,16 @@ ssh_input_thread(void *args)
gchstatus = CRYPT_OK; gchstatus = CRYPT_OK;
chan = -1; chan = -1;
} }
pthread_mutex_unlock(&ssh_mutex);
// Handle case where there was socket activity without readable data (ie: rekey) // Handle case where there was socket activity without readable data (ie: rekey)
if (popstatus == CRYPT_ERROR_TIMEOUT) { if (popstatus == CRYPT_ERROR_TIMEOUT) {
FlushData(ssh_session); FlushData(ssh_session);
pthread_mutex_unlock(&ssh_mutex);
continue; continue;
} }
// A final read on a channel just occured... figure out which is missing... // A final read on a channel just occured... figure out which is missing...
if (gchstatus == CRYPT_ERROR_NOTFOUND) { if (gchstatus == CRYPT_ERROR_NOTFOUND) {
pthread_mutex_lock(&ssh_mutex);
if (ssh_channel != -1) { if (ssh_channel != -1) {
FlushData(ssh_session); FlushData(ssh_session);
status = cryptSetAttribute(ssh_session, CRYPT_SESSINFO_SSH_CHANNEL, ssh_channel); status = cryptSetAttribute(ssh_session, CRYPT_SESSINFO_SSH_CHANNEL, ssh_channel);
...@@ -255,11 +254,9 @@ ssh_input_thread(void *args) ...@@ -255,11 +254,9 @@ ssh_input_thread(void *args)
} }
} }
} }
pthread_mutex_unlock(&ssh_mutex);
} }
if (cryptStatusOK(popstatus) && chan != -1) { if (cryptStatusOK(popstatus) && chan != -1) {
pthread_mutex_lock(&ssh_mutex);
if (chan == sftp_channel) { if (chan == sftp_channel) {
if (gchstatus == CRYPT_ERROR_NOTFOUND) { if (gchstatus == CRYPT_ERROR_NOTFOUND) {
sftp_channel = -1; sftp_channel = -1;
...@@ -278,9 +275,6 @@ ssh_input_thread(void *args) ...@@ -278,9 +275,6 @@ ssh_input_thread(void *args)
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
continue; continue;
} }
else {
pthread_mutex_unlock(&ssh_mutex);
}
} }
else if (chan == ssh_channel) { else if (chan == ssh_channel) {
if (gchstatus == CRYPT_ERROR_NOTFOUND) { if (gchstatus == CRYPT_ERROR_NOTFOUND) {
...@@ -296,12 +290,11 @@ ssh_input_thread(void *args) ...@@ -296,12 +290,11 @@ ssh_input_thread(void *args)
pthread_mutex_unlock(&(conn_inbuf.mutex)); pthread_mutex_unlock(&(conn_inbuf.mutex));
} }
} }
} pthread_mutex_lock(&ssh_mutex);
else {
pthread_mutex_unlock(&ssh_mutex);
} }
} }
FlushData(ssh_session); FlushData(ssh_session);
pthread_mutex_unlock(&ssh_mutex);
} }
conn_api.input_thread_running = 2; conn_api.input_thread_running = 2;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment