1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-11-27 04:46:26 +01:00

preference isset over array_key_exists, return false on failure, break after return channel opened

This commit is contained in:
montdidier 2015-03-24 13:38:56 +08:00
parent 1803bcac0b
commit 9723acc885
2 changed files with 7 additions and 2 deletions

View File

@ -2499,12 +2499,12 @@ class Net_SSH2
{
$channel = NET_SSH2_CHANNEL_EXEC;
do {
if (array_key_exists($channel, $this->channel_status) && $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_OPEN) {
if (isset($this->channel_status[$channel]) && $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_OPEN) {
return $channel;
}
} while ($channel++ < NET_SSH2_CHANNEL_SUBSYSTEM);
user_error("Unable to find an open channel");
return false;
}
/**
@ -2891,6 +2891,7 @@ class Net_SSH2
return false;
}
}
break;
default:
$packet = pack('CN3a*Na*',
NET_SSH2_MSG_REQUEST_FAILURE, $server_channel, NET_SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED, 0, '', 0, '');

View File

@ -374,6 +374,10 @@ class System_SSH_Agent
function _request_forwarding($ssh)
{
$request_channel = $ssh->_get_open_channel();
if ($request_channel === false) {
user_error("failed to request channel");
return false;
}
$packet = pack('CNNa*C',
NET_SSH2_MSG_CHANNEL_REQUEST, $ssh->server_channels[$request_channel], strlen('auth-agent-req@openssh.com'), 'auth-agent-req@openssh.com', 1);