From bd1506db932b3a60c9e70419da9357b2297d237c Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Fri, 25 Aug 2023 15:29:23 -0600 Subject: [PATCH] reset want read before attempting to read --- examples/client/client.c | 1 + src/internal.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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;