Skip to content

Commit

Permalink
reset want read before attempting to read
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobBarthelmeh committed Aug 25, 2023
1 parent 067cc06 commit bd1506d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ static int NonBlockSSH_connect(WOLFSSH* ssh)
select_ret == WS_SELECT_ERROR_READY)
{
ret = wolfSSH_connect(ssh);
error = wolfSSH_get_error(ssh);
}
else if (select_ret == WS_SELECT_TIMEOUT)
error = WS_WANT_READ;
Expand Down
8 changes: 7 additions & 1 deletion src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2264,8 +2264,14 @@ static int GetInputData(WOLFSSH* ssh, word32 size)

/* Take into account the data already in the buffer. Update size
* for what is missing in the request. */
word32 haveDataSz = ssh->inputBuffer.length - ssh->inputBuffer.idx;
word32 haveDataSz;

/* reset want read state before attempting to read */
if (ssh->error == WS_WANT_READ) {
ssh->error = 0;
}

haveDataSz = ssh->inputBuffer.length - ssh->inputBuffer.idx;
if (haveDataSz >= size) {
WLOG(WS_LOG_INFO, "GID: have enough already, return early");
return WS_SUCCESS;
Expand Down

0 comments on commit bd1506d

Please sign in to comment.