From 0dd929341b8d6bd5f5269438339e2b7be99f5355 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 26 May 2014 17:37:32 -0500 Subject: [PATCH] SSH2: make it so callback functions can make exec() return early --- phpseclib/Net/SSH2.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 25b7b9c0..b0c2ca16 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2227,7 +2227,7 @@ class Net_SSH2 * In all likelihood, this is not a feature you want to be taking advantage of. * * @param String $command - * @param optional Boolean $block + * @param optional Callback $callback * @return String * @access public */ @@ -2245,7 +2245,7 @@ class Net_SSH2 // be adjusted". 0x7FFFFFFF is, at 2GB, the max size. technically, it should probably be decremented, but, // honestly, if you're transfering more than 2GB, you probably shouldn't be using phpseclib, anyway. // see http://tools.ietf.org/html/rfc4254#section-5.2 for more info - $this->window_size_server_to_client[NET_SSH2_CHANNEL_EXEC] = 0x7FFFFFFF; + $this->window_size_server_to_client[NET_SSH2_CHANNEL_EXEC] = $this->window_size; // 0x8000 is the maximum max packet size, per http://tools.ietf.org/html/rfc4253#section-6.1, although since PuTTy // uses 0x4000, that's what will be used here, as well. $packet_size = 0x4000; @@ -2330,7 +2330,10 @@ class Net_SSH2 return false; default: if (is_callable($callback)) { - call_user_func($callback, $temp); + if (call_user_func($callback, $temp) === true) { + $this->_close_channel(NET_SSH2_CHANNEL_EXEC); + return true; + } } else { $output.= $temp; }