From d79ce65fe3b8d3ec9c1c0492ca12cf7c16c0b640 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 10 Jun 2013 10:57:34 -0500 Subject: [PATCH] SSH2: close channel and break after exit-signal Prior to https://github.com/phpseclib/phpseclib/commit/efdec7b118b1f8c24b9882ccc4a7fce5cb8d945f exit-signal's would re-use exit-status's channel closing code. after that commit, however, exit-status specific code was added, which meant that falling through, without the break, broke things --- phpseclib/Net/SSH2.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index c82d4d81..f2bde0e5 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2694,6 +2694,13 @@ class Net_SSH2 { if ($length) { $this->errors[count($this->errors)].= "\r\n" . $this->_string_shift($response, $length); } + + $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel])); + $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel])); + + $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_EOF; + + break; case 'exit-status': extract(unpack('Cfalse/Nexit_status', $this->_string_shift($response, 5))); $this->exit_status = $exit_status; @@ -2703,6 +2710,8 @@ class Net_SSH2 { $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel])); $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_EOF; + + break; default: // "Some systems may not implement signals, in which case they SHOULD ignore this message." // -- http://tools.ietf.org/html/rfc4254#section-6.9