From f3c98d4dfd5e5e266576c498a2fef776008ccc33 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Fri, 7 May 2021 14:10:52 +0700 Subject: [PATCH] fix for cleanup in error case --- src/wolfsftp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wolfsftp.c b/src/wolfsftp.c index aaa40095..0e4da4cc 100644 --- a/src/wolfsftp.c +++ b/src/wolfsftp.c @@ -6704,7 +6704,7 @@ int wolfSSH_SFTP_SendReadPacket(WOLFSSH* ssh, byte* handle, word32 handleSz, } WLOG(WS_LOG_SFTP, "Error reading remainder of data"); state->state = STATE_SEND_READ_CLEANUP; - continue; + break; } state->recvSz += ret; @@ -6712,6 +6712,11 @@ int wolfSSH_SFTP_SendReadPacket(WOLFSSH* ssh, byte* handle, word32 handleSz, wolfSSH_SFTP_buffer_size(&state->buffer) - ret); } while (wolfSSH_SFTP_buffer_size(&state->buffer) != 0); + if (ret < 0) { + /* error state was hit in earlier loop, continue on to + * cleanup */ + continue; + } ret = state->recvSz; state->state = STATE_SEND_READ_CLEANUP;