mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-21 14:00:51 +03:00
sftp_write: clean offsets on error
When an error has occurred on FXP_WRITE, we must make sure that the offset, sent offset and acked counter are reset properly.
This commit is contained in:
12
src/sftp.c
12
src/sftp.c
@@ -1681,6 +1681,18 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
|
||||
/* flush all pending packets from the outgoing list */
|
||||
sftp_packetlist_flush(handle);
|
||||
|
||||
/* since we return error now, the applicaton will not get any
|
||||
outstanding data acked, so we need to rewind the offset to
|
||||
where the application knows it has reached with acked data */
|
||||
handle->u.file.offset -= handle->u.file.acked;
|
||||
|
||||
/* then reset the offset_sent to be the same as the offset */
|
||||
handle->u.file.offset_sent = handle->u.file.offset;
|
||||
|
||||
/* clear the acked counter since we can have no pending data to
|
||||
ack after an error */
|
||||
handle->u.file.acked = 0;
|
||||
|
||||
/* the server returned an error for that written chunk, propagate
|
||||
this back to our parent function */
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
|
||||
Reference in New Issue
Block a user