diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-08-28 23:59:18 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-08-28 23:59:18 +0200 |
commit | bf9a82ad9a7b033a2903f2b8d477cb0657a4e068 (patch) | |
tree | 2d254f706f62a53773c66f22afd0050cc3a73941 /libssh/channels.c | |
parent | c1efcd28f596da1f09582298c99e557c3f1083c8 (diff) | |
download | libssh-bf9a82ad9a7b033a2903f2b8d477cb0657a4e068.tar.gz libssh-bf9a82ad9a7b033a2903f2b8d477cb0657a4e068.tar.xz libssh-bf9a82ad9a7b033a2903f2b8d477cb0657a4e068.zip |
Limit the size of packets in ssh_channel_write*
Diffstat (limited to 'libssh/channels.c')
-rw-r--r-- | libssh/channels.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libssh/channels.c b/libssh/channels.c index c99cfb45..cc921323 100644 --- a/libssh/channels.c +++ b/libssh/channels.c @@ -922,7 +922,10 @@ int channel_write_common(ssh_channel channel, const void *data, uint32_t len, int is_stderr) { ssh_session session = channel->session; int origlen = len; - int effectivelen; + size_t effectivelen; + /* handle the max packet len from remote side, be nice */ + /* 10 bytes for the headers */ + size_t maxpacketlen = channel->remote_maxpacket - 10; enter_function(); @@ -969,7 +972,7 @@ int channel_write_common(ssh_channel channel, const void *data, } else { effectivelen = len; } - + effectivelen = effectivelen > maxpacketlen ? maxpacketlen : effectivelen; if (buffer_add_u8(session->out_buffer, is_stderr ? SSH2_MSG_CHANNEL_EXTENDED_DATA : SSH2_MSG_CHANNEL_DATA) < 0 || buffer_add_u32(session->out_buffer, @@ -985,7 +988,7 @@ int channel_write_common(ssh_channel channel, const void *data, } ssh_log(session, SSH_LOG_RARE, - "channel_write wrote %d bytes", effectivelen); + "channel_write wrote %ld bytes", effectivelen); channel->remote_window -= effectivelen; len -= effectivelen; |