SFTP: limit write() to not produce overly large packets
sftp_write() now limits how much data it gets at a time even more than before. Since this function creates a complete outgoing packet based on what gets passed to it, it is crucial that it doesn't create too large packets. With this method, there's also no longer any problem to use very large buffers in your application and feed that to libssh2. I've done numerous tests now with uploading data over SFTP using 100K buffers and I've had no problems with that.
This commit is contained in:
parent
1785d0d6f3
commit
518d25eba1
@ -1402,12 +1402,9 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
|
||||
unsigned char *s, *data;
|
||||
int rc;
|
||||
|
||||
/* There's no point in us accepting a VERY large packet here since we
|
||||
cannot send it anyway. We just accept 4 times the big size to fill up
|
||||
the queue somewhat. */
|
||||
|
||||
if(count > (MAX_SSH_PACKET_LEN*4))
|
||||
count = MAX_SSH_PACKET_LEN*4;
|
||||
/* we limit this to just send a single SSH packet at a time */
|
||||
if(count > 32500)
|
||||
count = 32500;
|
||||
|
||||
packet_len = handle->handle_len + count + 25;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user