diff --git a/examples/client/client.c b/examples/client/client.c index 56eea6471..88c48d9fa 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -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; diff --git a/src/internal.c b/src/internal.c index 3d191d4a5..e23ba9ac3 100644 --- a/src/internal.c +++ b/src/internal.c @@ -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;