From b614ab4dc0598f8f7285e6daa16e0affc77c8a59 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Mon, 18 Apr 2011 21:37:06 +0000 Subject: [PATCH] - read(...) only returned first byte of matched string - not entire matched string git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@153 21d32557-59b3-4da0-833f-c5933fad653e --- phpseclib/Net/SSH2.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 954b6238..19c4298a 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -1778,15 +1778,13 @@ class Net_SSH2 { } while (true) { - if ($mode != NET_SSH2_READ_REGEX) { - $pos = strpos($this->interactiveBuffer, $expect); - } else { - $pos = preg_match($expect, $this->interactiveBuffer, $matches) ? - strpos($this->interactiveBuffer, $matches[0]) : - false; + if ($mode == NET_SSH2_READ_REGEX) { + preg_match($expect, $this->interactiveBuffer, $matches); + $expect = $matches[0]; } + $pos = strpos($this->interactiveBuffer, $expect); if ($pos !== false) { - return $this->_string_shift($this->interactiveBuffer, $pos + 1); + return $this->_string_shift($this->interactiveBuffer, $pos + strlen($expect)); } $response = $this->_get_channel_packet(NET_SSH2_CHANNEL_SHELL);