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

Check for CRYPT_ERROR_READ as well

cryptPopData() and cryptFlushData() will return CRYPT_ERROR_READ
if the socket is unexpectedly closed, not CRYPT_ERROR_COMPLETE.

Handle that in the wrappers as well.
parent 9dd5381b
No related branches found
No related tags found
No related merge requests found
Pipeline #7612 passed
...@@ -63,7 +63,7 @@ static int ...@@ -63,7 +63,7 @@ static int
FlushData(CRYPT_SESSION sess) FlushData(CRYPT_SESSION sess)
{ {
int ret = cryptFlushData(sess); int ret = cryptFlushData(sess);
if (ret == CRYPT_ERROR_COMPLETE) if (ret == CRYPT_ERROR_COMPLETE || ret == CRYPT_ERROR_READ)
ssh_complete = true; ssh_complete = true;
return ret; return ret;
} }
...@@ -74,7 +74,7 @@ PopData(CRYPT_HANDLE e, void *buf, int len, int *copied) ...@@ -74,7 +74,7 @@ PopData(CRYPT_HANDLE e, void *buf, int len, int *copied)
cryptSetAttribute(ssh_session, CRYPT_OPTION_NET_READTIMEOUT, 0); cryptSetAttribute(ssh_session, CRYPT_OPTION_NET_READTIMEOUT, 0);
int ret = cryptPopData(e, buf, len, copied); int ret = cryptPopData(e, buf, len, copied);
cryptSetAttribute(ssh_session, CRYPT_OPTION_NET_READTIMEOUT, 30); cryptSetAttribute(ssh_session, CRYPT_OPTION_NET_READTIMEOUT, 30);
if (ret == CRYPT_ERROR_COMPLETE) if (ret == CRYPT_ERROR_COMPLETE || ret == CRYPT_ERROR_READ)
ssh_complete = true; ssh_complete = true;
return ret; return ret;
} }
......
...@@ -32,7 +32,7 @@ static int ...@@ -32,7 +32,7 @@ static int
FlushData(CRYPT_SESSION sess) FlushData(CRYPT_SESSION sess)
{ {
int ret = cryptFlushData(sess); int ret = cryptFlushData(sess);
if (ret == CRYPT_ERROR_COMPLETE) if (ret == CRYPT_ERROR_COMPLETE || ret == CRYPT_ERROR_READ)
telnets_active = false; telnets_active = false;
return ret; return ret;
} }
...@@ -41,7 +41,7 @@ static int ...@@ -41,7 +41,7 @@ static int
PopData(CRYPT_HANDLE e, void *buf, int len, int *copied) PopData(CRYPT_HANDLE e, void *buf, int len, int *copied)
{ {
int ret = cryptPopData(e, buf, len, copied); int ret = cryptPopData(e, buf, len, copied);
if (ret == CRYPT_ERROR_COMPLETE) if (ret == CRYPT_ERROR_COMPLETE || ret == CRYPT_ERROR_READ)
telnets_active = false; telnets_active = false;
return ret; return ret;
} }
...@@ -116,7 +116,7 @@ telnets_output_thread(void *args) ...@@ -116,7 +116,7 @@ telnets_output_thread(void *args)
status = PushData(telnets_session, conn_api.wr_buf + sent, wr - sent, &ret); status = PushData(telnets_session, conn_api.wr_buf + sent, wr - sent, &ret);
pthread_mutex_unlock(&telnets_mutex); pthread_mutex_unlock(&telnets_mutex);
if (cryptStatusError(status)) { if (cryptStatusError(status)) {
if (status == CRYPT_ERROR_COMPLETE) { /* connection closed */ if (status == CRYPT_ERROR_COMPLETE || status == CRYPT_ERROR_READ) { /* connection closed */
telnets_active = false; telnets_active = false;
break; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment