Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/common-channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,17 +858,21 @@ void common_recv_msg_channel_data(struct Channel *channel, int fd,
void recv_msg_channel_window_adjust() {

struct Channel * channel;
unsigned int incr;
unsigned int incr, newwin;

channel = getchannel();

incr = buf_getint(ses.payload);
TRACE(("received window increment %d", incr))
incr = MIN(incr, TRANS_MAX_WIN_INCR);
TRACE(("received window increment %u", incr))

channel->transwindow += incr;
channel->transwindow = MIN(channel->transwindow, TRANS_MAX_WINDOW);

newwin = channel->transwindow + incr;
if (newwin < channel->transwindow) {
/* Integer overflow, clamp it at maximum.
* Behaviour may be unexpected, senders MUST NOT overflow per rfc4254. */
TRACE(("overflow window, prev %u", channel->transwindow));
newwin = 0xffffffff;
}
channel->transwindow = newwin;
}

/* Increment the incoming data window for a channel, and let the remote
Expand Down Expand Up @@ -906,7 +910,6 @@ void recv_msg_channel_open() {

remotechan = buf_getint(ses.payload);
transwindow = buf_getint(ses.payload);
transwindow = MIN(transwindow, TRANS_MAX_WINDOW);
transmaxpacket = buf_getint(ses.payload);
transmaxpacket = MIN(transmaxpacket, TRANS_MAX_PAYLOAD_LEN);

Expand Down
3 changes: 0 additions & 3 deletions src/sysoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
#define RECV_MAX_PACKET_LEN (MAX(35000, ((RECV_MAX_PAYLOAD_LEN)+100)))

/* for channel code */
#define TRANS_MAX_WINDOW 500000000 /* 500MB is sufficient, stopping overflow */
#define TRANS_MAX_WIN_INCR 500000000 /* overflow prevention */

#define RECV_WINDOWEXTEND (opts.recv_window / 3) /* We send a "window extend" every
RECV_WINDOWEXTEND bytes */
#define MAX_RECV_WINDOW (10*1024*1024) /* 10 MB should be enough */
Expand Down