From 4862400a374253216e596ff5c3b018b857015cbb Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Mon, 6 Oct 2025 00:42:05 -0600 Subject: [PATCH] fix spelling issues and SFTP send state --- .github/workflows/sshd-test.yml | 2 +- examples/client/client.c | 4 ++-- examples/sftpclient/sftpclient.c | 7 ++++--- src/internal.c | 2 +- src/wolfsftp.c | 15 +++++++++------ 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/sshd-test.yml b/.github/workflows/sshd-test.yml index eb075a6f..3fbe3daf 100644 --- a/.github/workflows/sshd-test.yml +++ b/.github/workflows/sshd-test.yml @@ -66,7 +66,7 @@ jobs: wolfssl: ${{ fromJson(needs.create_matrix.outputs['versions']) }} name: Build and test wolfsshd runs-on: ${{ matrix.os }} - timeout-minutes: 15 + timeout-minutes: 10 steps: - name: Checking cache for wolfssl uses: actions/cache@v4 diff --git a/examples/client/client.c b/examples/client/client.c index f415bd80..49d00f44 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -481,10 +481,10 @@ static THREAD_RET readPeer(void* in) } } else if (ret != WS_EOF) { - if (ret == 0) { + if (ret == 0) { bytes = 0; continue; - } + } err_sys("Stream read failed."); } } diff --git a/examples/sftpclient/sftpclient.c b/examples/sftpclient/sftpclient.c index 1194b0de..e074b3d1 100644 --- a/examples/sftpclient/sftpclient.c +++ b/examples/sftpclient/sftpclient.c @@ -1184,7 +1184,7 @@ static int doAutopilot(int cmd, char* local, char* remote) } do { - if (err == WS_REKEYING) { /* handle rekeying state */ + if (err == WS_REKEYING || err == WS_WINDOW_FULL) { /* handle rekeying state */ do { ret = wolfSSH_worker(ssh, NULL); } while (ret == WS_REKEYING); @@ -1198,7 +1198,8 @@ static int doAutopilot(int cmd, char* local, char* remote) } err = wolfSSH_get_error(ssh); } while ((err == WS_WANT_READ || err == WS_WANT_WRITE || - err == WS_CHAN_RXD || err == WS_REKEYING) && + err == WS_CHAN_RXD || err == WS_REKEYING || + err == WS_WINDOW_FULL) && ret == WS_FATAL_ERROR); if (ret != WS_SUCCESS) { @@ -1504,7 +1505,7 @@ THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args) ret = wolfSSH_worker(ssh, NULL); err = wolfSSH_get_error(ssh); - /* peer succesfully closed down gracefully */ + /* peer successfully closed down gracefully */ if (ret == WS_CHANNEL_CLOSED) { ret = 0; break; diff --git a/src/internal.c b/src/internal.c index ff912ef7..b9e3a343 100644 --- a/src/internal.c +++ b/src/internal.c @@ -605,7 +605,7 @@ INLINE static int IsMessageAllowedKeying(WOLFSSH *ssh, byte msg) return 1; } - /* case of servie request or accept in 1-19 */ + /* case of service request or accept in 1-19 */ if (msg == MSGID_SERVICE_REQUEST || msg == MSGID_SERVICE_ACCEPT) { WLOG(WS_LOG_DEBUG, "Message ID %u not allowed by during rekeying", msg); ssh->error = WS_REKEYING; diff --git a/src/wolfsftp.c b/src/wolfsftp.c index 53c5dfd1..998806ae 100644 --- a/src/wolfsftp.c +++ b/src/wolfsftp.c @@ -416,6 +416,7 @@ static INLINE int NoticeError(WOLFSSH* ssh) return (ssh->error == WS_WANT_READ || ssh->error == WS_WANT_WRITE || ssh->error == WS_CHAN_RXD || + ssh->error == WS_WINDOW_FULL || ssh->error == WS_REKEYING); } @@ -865,7 +866,6 @@ static int SFTP_GetHeader(WOLFSSH* ssh, word32* reqId, byte* type, */ static int SFTP_SetHeader(WOLFSSH* ssh, word32 reqId, byte type, word32 len, byte* buf) { - c32toa(len + LENGTH_SZ + MSG_ID_SZ, buf); buf[LENGTH_SZ] = type; c32toa(reqId, buf + LENGTH_SZ + MSG_ID_SZ); @@ -7471,12 +7471,15 @@ int wolfSSH_SFTP_SendWritePacket(WOLFSSH* ssh, byte* handle, word32 handleSz, case STATE_SEND_WRITE_SEND_BODY: WLOG(WS_LOG_SFTP, "SFTP SEND_WRITE STATE: SEND_BODY"); state->sentSz = wolfSSH_stream_send(ssh, in, inSz); - if (NoticeError(ssh)) { - return WS_FATAL_ERROR; - } if (state->sentSz <= 0) { - ssh->error = state->sentSz; ret = WS_FATAL_ERROR; + if (NoticeError(ssh)) { + ret = wolfSSH_worker(ssh,NULL); + continue; + } + + /* if it was not a notice error then clean up the state and + * exit out */ state->state = STATE_SEND_WRITE_CLEANUP; continue; } @@ -9170,7 +9173,7 @@ int wolfSSH_SFTP_Put(WOLFSSH* ssh, char* from, char* to, byte resume, if (sz <= 0) { if (NoticeError(ssh)) { return WS_FATAL_ERROR; - } + } } else { AddAssign64(state->pOfst, sz);