From 1e4773e49bc8626172abc3312257abbd40ef4df2 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Mon, 3 Aug 2026 13:42:28 -0700 Subject: [PATCH] wolfsftp: check the resume seek in wolfSSH_SFTP_Put A failed WFSEEK() left the local file at offset 0 while the remote write continued from the resume offset, silently corrupting the upload. Fail out through the local close instead, the file is open at that point. Issue: CID-572932 --- src/wolfsftp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wolfsftp.c b/src/wolfsftp.c index 7310be2e..9a52dc49 100644 --- a/src/wolfsftp.c +++ b/src/wolfsftp.c @@ -10053,7 +10053,15 @@ int wolfSSH_SFTP_Put(WOLFSSH* ssh, char* from, char* to, byte resume, #if SIZEOF_OFF_T == 8 offset = (((word64)state->pOfst[1]) << 32) | offset; #endif - WFSEEK(ssh->fs, state->fl, offset, 0); + if (WFSEEK(ssh->fs, state->fl, offset, 0) != 0) { + WLOG(WS_LOG_SFTP, "Unable to seek input file"); + ssh->error = WS_BAD_FILE_E; + ret = WS_FATAL_ERROR; + /* no remote handle to close yet */ + state->handleSz = 0; + state->state = STATE_PUT_CLOSE_LOCAL; + continue; + } } #else /* USE_WINDOWS_API */ state->fileHandle = WS_CreateFileA(from, GENERIC_READ,