mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
sftp: Handle short reads of sftp_async_read().
sftp_async_read() and sftp_async_read_begin() assume that the whole read
will be successful but when this is not the case, the offset will be
wrong.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit d1df255df4)
This commit is contained in:
committed by
Andreas Schneider
parent
ac445a1e18
commit
661722753b
@@ -1945,9 +1945,8 @@ int sftp_async_read(sftp_file file, void *data, uint32_t size, uint32_t id){
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
len = ssh_string_len(datastring);
|
len = ssh_string_len(datastring);
|
||||||
//handle->offset+=len;
|
/* Update the offset with the correct value */
|
||||||
/* We already have set the offset previously. All we can do is warn that the expected len
|
file->offset = file->offset - (size - len);
|
||||||
* and effective lengths are different */
|
|
||||||
memcpy(data, ssh_string_data(datastring), len);
|
memcpy(data, ssh_string_data(datastring), len);
|
||||||
ssh_string_free(datastring);
|
ssh_string_free(datastring);
|
||||||
sftp_leave_function();
|
sftp_leave_function();
|
||||||
|
|||||||
Reference in New Issue
Block a user