From dd0b3e6bd569377a65e05c2038802a2750b0571f Mon Sep 17 00:00:00 2001 From: montdidier Date: Mon, 12 Jan 2015 17:13:33 +0800 Subject: [PATCH] addresses low hanging fruit comments from terrafrost and bantu --- phpseclib/Net/SSH2.php | 7 +------ phpseclib/System/SSH/Agent.php | 2 +- tests/Functional/Net/SSH2AgentTest.php | 2 ++ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 9ae7d176..0a649fd9 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -101,8 +101,6 @@ define('NET_SSH2_CHANNEL_SHELL', 1); define('NET_SSH2_CHANNEL_SUBSYSTEM', 2); define('NET_SSH2_CHANNEL_AGENT_REQUEST', 3); define('NET_SSH2_CHANNEL_AGENT_FORWARD', 4); - - /**#@-*/ /**#@+ @@ -2248,7 +2246,6 @@ class Net_SSH2 return false; } - /** * Set Timeout * @@ -2825,8 +2822,6 @@ class Net_SSH2 } $payload = $this->_get_binary_packet(); } - default: - break; } // see http://tools.ietf.org/html/rfc4252#section-5.4; only called when the encryption has been activated and when we haven't already logged in @@ -3007,7 +3002,7 @@ class Net_SSH2 } switch ($this->channel_status[$channel]) { - case NET_SSH2_MSG_CHANNEL_OPEN:; + case NET_SSH2_MSG_CHANNEL_OPEN: switch ($type) { case NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION: extract(unpack('Nserver_channel', $this->_string_shift($response, 4))); diff --git a/phpseclib/System/SSH/Agent.php b/phpseclib/System/SSH/Agent.php index 47146045..1b09a34d 100644 --- a/phpseclib/System/SSH/Agent.php +++ b/phpseclib/System/SSH/Agent.php @@ -437,7 +437,7 @@ class System_SSH_Agent function _forward_data($data) { if ($this->expected_bytes > 0) { - $this->socket_buffer .= $data; + $this->socket_buffer.= $data; $this->expected_bytes -= strlen($data); } else { $agent_data_bytes = current(unpack('N', $data)); diff --git a/tests/Functional/Net/SSH2AgentTest.php b/tests/Functional/Net/SSH2AgentTest.php index 1426f66c..af79b60d 100644 --- a/tests/Functional/Net/SSH2AgentTest.php +++ b/tests/Functional/Net/SSH2AgentTest.php @@ -46,7 +46,9 @@ class Functional_Net_SSH2AgentTest extends PhpseclibFunctionalTestCase $agent->startSSHForwarding($ssh); $this->assertEquals($username, trim($ssh->exec("ssh " . $username . "@" . $hostname . ' \'whoami\''))); + $agent->stopSSHForwarding($ssh); + $this->assertEquals($username, 'failure'); return $args; }