From 467e064dce7331724463bb528a062fe83c4fb647 Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 4 Aug 2007 14:32:06 +0000 Subject: [PATCH] Tweak to window handling: Keep the local window in a signed integer, and arrange to handle usefully the case where the server sends us more data than it's allowed to. There's no danger of overflow, since the maximum is OUR_V2_WINSIZE and the minimum is -OUR_V2_MAXPKT (at least if the server is nice). git-svn-id: svn://svn.tartarus.org/sgt/putty@7661 cda61777-01e9-0310-a592-d414129be87e --- ssh.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ssh.c b/ssh.c index 3476d3d8..4f69201b 100644 --- a/ssh.c +++ b/ssh.c @@ -551,7 +551,8 @@ struct ssh_channel { struct ssh2_data_channel { bufchain outbuffer; unsigned remwindow, remmaxpkt; - unsigned locwindow; + /* locwindow is signed so we can cope with excess data. */ + int locwindow; } v2; } v; union { @@ -6284,9 +6285,12 @@ static void ssh2_msg_channel_data(Ssh ssh, struct Packet *pktin) /* * If we are not buffering too much data, * enlarge the window again at the remote side. + * If we are buffering too much, we may still + * need to adjust the window if the server's + * sent excess data. */ - if (bufsize < OUR_V2_WINSIZE) - ssh2_set_window(c, OUR_V2_WINSIZE - bufsize); + ssh2_set_window(c, bufsize < OUR_V2_WINSIZE ? + OUR_V2_WINSIZE - bufsize : 0); } } -- 2.11.0