Skip to content

Commit

Permalink
SSH2: present a less cryptic error message when channel isn't open
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Feb 7, 2023
1 parent 2487192 commit 4a79a24
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions phpseclib/Net/SSH2.php
Expand Up @@ -4323,6 +4323,11 @@ protected function send_channel_packet($client_channel, $data)
*/
private function close_channel($client_channel, $want_reply = false)
{
if (!isset($this->server_channels[$client_channel])) {
$this->disconnect_helper(NET_SSH2_DISCONNECT_CONNECTION_LOST);
throw new \RuntimeException('Unable to close a channel that was never opened');
}

// see http://tools.ietf.org/html/rfc4254#section-5.3

$this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel]));
Expand Down

0 comments on commit 4a79a24

Please sign in to comment.