- 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
This commit is contained in:
Jim Wigginton 2011-04-18 21:37:06 +00:00
parent 392d96445e
commit b614ab4dc0

View File

@ -1778,15 +1778,13 @@ class Net_SSH2 {
} }
while (true) { while (true) {
if ($mode != NET_SSH2_READ_REGEX) { if ($mode == NET_SSH2_READ_REGEX) {
$pos = strpos($this->interactiveBuffer, $expect); preg_match($expect, $this->interactiveBuffer, $matches);
} else { $expect = $matches[0];
$pos = preg_match($expect, $this->interactiveBuffer, $matches) ?
strpos($this->interactiveBuffer, $matches[0]) :
false;
} }
$pos = strpos($this->interactiveBuffer, $expect);
if ($pos !== false) { 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); $response = $this->_get_channel_packet(NET_SSH2_CHANNEL_SHELL);