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
pull/1140/head
John Safranek 2026-08-03 13:42:28 -07:00 committed by Ruby Martin
parent 5f99058cbe
commit 1e4773e49b
1 changed files with 9 additions and 1 deletions

View File

@ -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,