Skip to content

Commit 327a3b8

Browse files
committed
SSH2: Keep track of client -> server window size
1 parent 23d48c4 commit 327a3b8

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

phpseclib/Net/SSH2.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class Net_SSH2 {
542542
var $window_size = 0x7FFFFFFF;
543543

544544
/**
545-
* Window size
545+
* Window size, server to client
546546
*
547547
* Window size indexed by channel
548548
*
@@ -552,6 +552,17 @@ class Net_SSH2 {
552552
*/
553553
var $window_size_server_to_client = array();
554554

555+
/**
556+
* Window size, client to server
557+
*
558+
* Window size indexed by channel
559+
*
560+
* @see Net_SSH2::_get_channel_packet()
561+
* @var Array
562+
* @access private
563+
*/
564+
var $window_size_client_to_server = array();
565+
555566
/**
556567
* Server signature
557568
*
@@ -2536,6 +2547,11 @@ function _filter($payload)
25362547
$payload = $this->_get_binary_packet();
25372548
break;
25382549
case NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST:
2550+
$this->_string_shift($payload, 1);
2551+
extract(unpack('Nchannel', $this->_string_shift($payload, 4)));
2552+
extract(unpack('Nwindow_size', $this->_string_shift($payload, 4)));
2553+
$this->window_size_client_to_server[$channel] = $window_size;
2554+
25392555
$payload = $this->_get_binary_packet();
25402556
}
25412557
}
@@ -2651,7 +2667,8 @@ function _get_channel_packet($client_channel, $skip_extended = false)
26512667
case NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION:
26522668
extract(unpack('Nserver_channel', $this->_string_shift($response, 4)));
26532669
$this->server_channels[$channel] = $server_channel;
2654-
$this->_string_shift($response, 4); // skip over (server) window size
2670+
extract(unpack('Nwindow_size', $this->_string_shift($response, 4)));
2671+
$this->window_size_client_to_server[$channel] = $window_size;
26552672
$temp = unpack('Npacket_size_client_to_server', $this->_string_shift($response, 4));
26562673
$this->packet_size_client_to_server[$channel] = $temp['packet_size_client_to_server'];
26572674
return $client_channel == $channel ? true : $this->_get_channel_packet($client_channel, $skip_extended);
@@ -2924,6 +2941,8 @@ function _send_channel_packet($client_channel, $data)
29242941
}
29252942
}
29262943

2944+
$this->window_size_client_to_server[$client_channel]-= strlen($data);
2945+
29272946
return $this->_send_binary_packet(pack('CN2a*',
29282947
NET_SSH2_MSG_CHANNEL_DATA,
29292948
$this->server_channels[$client_channel],

0 commit comments

Comments
 (0)