Merge pull request #1222 from rrran/extract_func_phpdoc

Add PhpDoc @var for extract() functions
This commit is contained in:
terrafrost 2017-12-23 14:18:28 -06:00 committed by GitHub
commit 239a32ff06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 184 additions and 23 deletions

View File

@ -117,6 +117,7 @@ abstract class PuTTY
$source = Strings::packSSH2('ssss', static::TYPE, $encryption, $components['comment'], $public);
extract(unpack('Nlength', Strings::shift($public, 4)));
/** @var integer $length */
if (Strings::shift($public, $length) != static::TYPE) {
return false;
}

View File

@ -63,21 +63,23 @@ abstract class PuTTY extends Progenitor
if ($components === false || !isset($components['private'])) {
return $components;
}
extract($components);
unset($components['public'], $components['private']);
$result = Strings::unpackSSH2('iiii', $public);
$result = Strings::unpackSSH2('iiii', $components['public']);
if ($result === false) {
return false;
}
list($p, $q, $g, $y) = $result;
$result = Strings::unpackSSH2('i', $private);
$result = Strings::unpackSSH2('i', $components['private']);
if ($result === false) {
return false;
}
list($x) = $result;
if (isset($components['comment'])) {
$comment = $components['comment'];
}
return compact('p', 'q', 'g', 'y', 'x', 'comment');
}

View File

@ -383,6 +383,9 @@ class RSA extends AsymmetricKey
$primes[$i] = BigInteger::randomPrime($regSize);
} else {
extract(BigInteger::minMaxBits($bits));
/** @var BigInteger $min
* @var BigInteger $max
*/
list($min) = $min->divide($n);
$min = $min->add(self::$one);
list($max) = $max->divide($n);

View File

@ -88,6 +88,12 @@ abstract class MSBLOB
// PUBLICKEYSTRUC publickeystruc
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa387453(v=vs.85).aspx
extract(unpack('atype/aversion/vreserved/Valgo', Strings::shift($key, 8)));
/**
* @var string $type
* @var string $version
* @var integer $reserved
* @var integer $algo
*/
switch (ord($type)) {
case self::PUBLICKEYBLOB:
case self::PUBLICKEYBLOBEX:
@ -115,6 +121,11 @@ abstract class MSBLOB
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa387685(v=vs.85).aspx
// could do V for pubexp but that's unsigned 32-bit whereas some PHP installs only do signed 32-bit
extract(unpack('Vmagic/Vbitlen/a4pubexp', Strings::shift($key, 12)));
/**
* @var integer $magic
* @var integer $bitlen
* @var string $pubexp
*/
switch ($magic) {
case self::RSA2:
$components['isPublicKey'] = false;

View File

@ -63,18 +63,16 @@ abstract class PuTTY extends Progenitor
if ($components === false || !isset($components['private'])) {
return $components;
}
extract($components);
unset($components['public'], $components['private']);
$isPublicKey = false;
$result = Strings::unpackSSH2('ii', $public);
$result = Strings::unpackSSH2('ii', $components['public']);
if ($result === false) {
return false;
}
list($publicExponent, $modulus) = $result;
$result = Strings::unpackSSH2('iiii', $private);
$result = Strings::unpackSSH2('iiii', $components['private']);
if ($result === false) {
return false;
}
@ -86,6 +84,10 @@ abstract class PuTTY extends Progenitor
$temp = $primes[2]->subtract($one);
$exponents[] = $publicExponent->modInverse($temp);
if (isset($components['comment'])) {
$comment = $components['comment'];
}
return compact('publicExponent', 'modulus', 'privateExponent', 'primes', 'coefficients', 'exponents', 'comment', 'isPublicKey');
}

View File

@ -292,6 +292,7 @@ abstract class ASN1
$current+= ['headerlength' => $length + 2];
$start+= $length;
extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)));
/** @var integer $length */
} else {
$current+= ['headerlength' => 2];
}

View File

@ -299,12 +299,17 @@ class BigInteger implements \Serializable
* Calculates modular inverses.
*
* Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
* @return array
* @return BigInteger[]
* @param BigInteger $n
*/
public function extendedGCD(BigInteger $n)
{
extract($this->value->extendedGCD($n->value));
/**
* @var BigInteger $gcd
* @var BigInteger $x
* @var BigInteger $y
*/
return [
'gcd' => new static($gcd),
'x' => new static($x),
@ -561,12 +566,15 @@ class BigInteger implements \Serializable
* Returns the smallest and largest n-bit number
*
* @param int $bits
* @return array
* @return BigInteger[]
*/
public static function minMaxBits($bits)
{
$class = self::$mainEngine;
extract($class::minMaxBits($bits));
/** @var BigInteger $min
* @var BigInteger $max
*/
return [
'min' => new static($min),
'max' => new static($max)

View File

@ -341,6 +341,7 @@ class BCMath extends Engine
public function gcd(BCMath $n)
{
extract($this->extendedGCD($n));
/** @var BCMath $gcd */
return $gcd;
}

View File

@ -18,6 +18,7 @@ namespace phpseclib\Math\BigInteger\Engines;
use ParagonIE\ConstantTime\Hex;
use phpseclib\Exception\BadConfigurationException;
use phpseclib\Crypt\Random;
use phpseclib\Math\BigInteger;
/**
* Base Engine.
@ -276,6 +277,10 @@ abstract class Engine implements \Serializable
}
extract($this->extendedGCD($n));
/**
* @var BigInteger $gcd
* @var BigInteger $x
*/
if (!$gcd->equals(static::$one)) {
return false;
@ -517,7 +522,7 @@ abstract class Engine implements \Serializable
* Returns the smallest and largest n-bit number
*
* @param int $bits
* @return \phpseclib\Math\BigInteger\Engines\Engine
* @return \phpseclib\Math\BigInteger\Engines\Engine[]
*/
public static function minMaxBits($bits)
{
@ -670,6 +675,10 @@ abstract class Engine implements \Serializable
public static function random($size)
{
extract(static::minMaxBits($size));
/**
* @var BigInteger $min
* @var BigInteger $max
*/
return static::randomRange($min, $max);
}
@ -684,6 +693,10 @@ abstract class Engine implements \Serializable
public static function randomPrime($size)
{
extract(static::minMaxBits($size));
/**
* @var BigInteger $min
* @var BigInteger $max
*/
return static::randomRangePrime($min, $max);
}

View File

@ -309,7 +309,7 @@ class GMP extends Engine
* {@link http://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity Bezout's identity - Wikipedia} for more information.
*
* @param \phpseclib\Math\BigInteger\Engines\GMP $n
* @return \phpseclib\Math\BigInteger\Engines\GMP
* @return \phpseclib\Math\BigInteger\Engines\GMP[]
*/
public function extendedGCD(GMP $n)
{

View File

@ -192,8 +192,7 @@ class PHP32 extends PHP
*/
public function gcd(PHP32 $n)
{
extract($this->extendedGCD($n));
return $gcd;
return $this->extendedGCD($n)['gcd'];
}
/**

View File

@ -192,8 +192,7 @@ class PHP64 extends PHP
*/
public function gcd(PHP64 $n)
{
extract($this->extendedGCD($n));
return $gcd;
return $this->extendedGCD($n)['gcd'];
}
/**

View File

@ -307,6 +307,8 @@ class SCP
return false;
}
extract(unpack('Nlength', $response[SSH1::RESPONSE_DATA]));
/** @var integer $length */
return Strings::shift($response[SSH1::RESPONSE_DATA], $length);
case NET_SSH1_SMSG_STDERR_DATA:
break;

View File

@ -494,17 +494,23 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nversion', Strings::shift($response, 4)));
/** @var integer $version */
$this->version = $version;
while (!empty($response)) {
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$key = Strings::shift($response, $length);
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$value = Strings::shift($response, $length);
$this->extensions[$key] = $value;
}
@ -638,12 +644,15 @@ class SFTP extends SSH2
return;
}
extract(unpack('Nstatus', Strings::shift($response, 4)));
/** @var integer $status */
}
$error = $this->status_codes[$status];
if ($this->version > 2 || strlen($response) < 4) {
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$this->sftp_errors[] = $error . ': ' . Strings::shift($response, $length);
} else {
$this->sftp_errors[] = $error;
@ -688,6 +697,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
return Strings::shift($response, $length);
case NET_SFTP_STATUS:
$this->logError($response);
@ -927,16 +938,22 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Ncount', Strings::shift($response, 4)));
/** @var integer $count */
for ($i = 0; $i < $count; $i++) {
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$shortname = Strings::shift($response, $length);
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$longname = Strings::shift($response, $length);
$attributes = $this->parseAttributes($response);
if (!isset($attributes['type'])) {
@ -966,6 +983,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nstatus', Strings::shift($response, 4)));
/** @var integer $status */
if ($status != NET_SFTP_STATUS_EOF) {
$this->logError($response, $status);
return false;
@ -1567,6 +1586,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nstatus', Strings::shift($response, 4)));
/** @var integer $status */
if ($status != NET_SFTP_STATUS_OK) {
$this->logError($response, $status);
return false;
@ -1683,6 +1704,7 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Ncount', Strings::shift($response, 4)));
/** @var integer $count */
// the file isn't a symlink
if (!$count) {
return false;
@ -1692,6 +1714,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
return Strings::shift($response, $length);
}
@ -1730,6 +1754,7 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nstatus', Strings::shift($response, 4)));
/** @var integer $status */
if ($status != NET_SFTP_STATUS_OK) {
$this->logError($response, $status);
@ -1800,6 +1825,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nstatus', Strings::shift($response, 4)));
/** @var integer $status */
if ($status != NET_SFTP_STATUS_OK) {
$this->logError($response, $status);
return false;
@ -1841,6 +1868,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nstatus', Strings::shift($response, 4)));
/** @var integer $status */
if ($status != NET_SFTP_STATUS_OK) {
// presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED?
$this->logError($response, $status);
@ -2079,6 +2108,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nstatus', Strings::shift($response, 4)));
/** @var integer $status */
if ($status != NET_SFTP_STATUS_OK) {
$this->logError($response, $status);
break;
@ -2114,6 +2145,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nstatus', Strings::shift($response, 4)));
/** @var integer $status */
if ($status != NET_SFTP_STATUS_OK) {
$this->logError($response, $status);
return false;
@ -2319,6 +2352,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nstatus', Strings::shift($response, 4)));
/** @var integer $status */
if ($status != NET_SFTP_STATUS_OK) {
$this->logError($response, $status);
if (!$recursive) {
@ -2749,6 +2784,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nstatus', Strings::shift($response, 4)));
/** @var integer $status */
if ($status != NET_SFTP_STATUS_OK) {
$this->logError($response, $status);
return false;
@ -2780,6 +2817,8 @@ class SFTP extends SSH2
return [];
}
extract(unpack('Nflags', Strings::shift($response, 4)));
/** @var integer $flags */
// SFTPv4+ have a type field (a byte) that follows the above flag field
foreach ($this->attributes as $key => $value) {
switch ($flags & $key) {
@ -2826,18 +2865,25 @@ class SFTP extends SSH2
return $attr;
}
extract(unpack('Ncount', Strings::shift($response, 4)));
/** @var integer $count */
for ($i = 0; $i < $count; $i++) {
if (strlen($response) < 4) {
//user_error('Malformed file attributes');
return $attr;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$key = Strings::shift($response, $length);
if (strlen($response) < 4) {
//user_error('Malformed file attributes');
return $attr;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$attr[$key] = Strings::shift($response, $length);
}
}
@ -2994,6 +3040,8 @@ class SFTP extends SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($this->packet_buffer, 4)));
/** @var integer $length */
$tempLength = $length;
$tempLength-= strlen($this->packet_buffer);

View File

@ -614,6 +614,7 @@ class SSH1
return false;
}
extract(unpack('Nsupported_ciphers_mask', Strings::shift($response[self::RESPONSE_DATA], 4)));
/** @var integer $supported_ciphers_mask */
foreach ($this->supported_ciphers as $mask => $name) {
if (($supported_ciphers_mask & (1 << $mask)) == 0) {
@ -626,6 +627,8 @@ class SSH1
return false;
}
extract(unpack('Nsupported_authentications_mask', Strings::shift($response[self::RESPONSE_DATA], 4)));
/** @var integer $supported_authentications_mask */
foreach ($this->supported_authentications as $mask => $name) {
if (($supported_authentications_mask & (1 << $mask)) == 0) {
unset($this->supported_authentications[$mask]);

View File

@ -1548,7 +1548,7 @@ class SSH2
return false;
}
extract(unpack('Cfirst_kex_packet_follows', Strings::shift($response, 1)));
/** @var integer $first_kex_packet_follows */
$first_kex_packet_follows = $first_kex_packet_follows != 0;
if (!$this->send_kex_first && !$this->send_binary_packet($kexinit_payload_client)) {
@ -1612,6 +1612,7 @@ class SSH2
return false;
}
extract(unpack('Ctype', Strings::shift($response, 1)));
/** @var integer $type */
if ($type != NET_SSH2_MSG_KEXDH_GEX_GROUP) {
user_error('Expected SSH_MSG_KEX_DH_GEX_GROUP');
return false;
@ -1621,6 +1622,7 @@ class SSH2
return false;
}
extract(unpack('NprimeLength', Strings::shift($response, 4)));
/** @var integer $primeLength*/
$primeBytes = Strings::shift($response, $primeLength);
$prime = new BigInteger($primeBytes, -256);
@ -1628,6 +1630,7 @@ class SSH2
return false;
}
extract(unpack('NgLength', Strings::shift($response, 4)));
/** @var integer $gLength */
$gBytes = Strings::shift($response, $gLength);
$g = new BigInteger($gBytes, -256);
@ -1711,7 +1714,7 @@ class SSH2
return false;
}
extract(unpack('Ctype', Strings::shift($response, 1)));
/** @var integer $type */
if ($type != $serverKexReplyMessage) {
throw new \UnexpectedValueException('Expected SSH_MSG_KEXDH_REPLY');
}
@ -1816,7 +1819,7 @@ class SSH2
return false;
}
extract(unpack('Ctype', Strings::shift($response, 1)));
/** @var integer $type */
if ($type != NET_SSH2_MSG_NEWKEYS) {
throw new \UnexpectedValueException('Expected SSH_MSG_NEWKEYS');
}
@ -2183,7 +2186,7 @@ class SSH2
return false;
}
extract(unpack('Ctype', Strings::shift($response, 1)));
/** @var integer $type */
if ($type != NET_SSH2_MSG_SERVICE_ACCEPT) {
throw new \UnexpectedValueException('Expected SSH_MSG_SERVICE_ACCEPT');
}
@ -2233,7 +2236,7 @@ class SSH2
return false;
}
extract(unpack('Ctype', Strings::shift($response, 1)));
/** @var integer $type */
switch ($type) {
case NET_SSH2_MSG_USERAUTH_SUCCESS:
$this->bitmap |= self::MASK_LOGIN;
@ -2290,7 +2293,7 @@ class SSH2
return false;
}
extract(unpack('Ctype', Strings::shift($response, 1)));
/** @var integer $type */
switch ($type) {
case NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ: // in theory, the password can be changed
if (defined('NET_SSH2_LOGGING')) {
@ -2301,6 +2304,8 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$this->errors[] = 'SSH_MSG_USERAUTH_PASSWD_CHANGEREQ: ' . utf8_decode(Strings::shift($response, $length));
return $this->disconnect_helper(NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER);
@ -2311,11 +2316,15 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$auth_methods = explode(',', Strings::shift($response, $length));
if (!strlen($response)) {
return false;
}
extract(unpack('Cpartial_success', Strings::shift($response, 1)));
/** @var integer $partial_success */
$partial_success = $partial_success != 0;
if (!$partial_success && in_array('keyboard-interactive', $auth_methods)) {
@ -2391,28 +2400,35 @@ class SSH2
return false;
}
extract(unpack('Ctype', Strings::shift($response, 1)));
/** @var integer $type */
switch ($type) {
case NET_SSH2_MSG_USERAUTH_INFO_REQUEST:
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
Strings::shift($response, $length); // name; may be empty
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
Strings::shift($response, $length); // instruction; may be empty
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
Strings::shift($response, $length); // language tag; may be empty
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nnum_prompts', Strings::shift($response, 4)));
/** @var integer $num_prompts */
for ($i = 0; $i < count($responses); $i++) {
if (is_array($responses[$i])) {
@ -2430,6 +2446,8 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
// prompt - ie. "Password: "; must not be empty
$prompt = Strings::shift($response, $length);
//$echo = Strings::shift($response) != chr(0);
@ -2578,6 +2596,7 @@ class SSH2
return false;
}
extract(unpack('Ctype', Strings::shift($response, 1)));
/** @var integer $type */
switch ($type) {
case NET_SSH2_MSG_USERAUTH_FAILURE:
@ -2585,6 +2604,8 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$this->errors[] = 'SSH_MSG_USERAUTH_FAILURE: ' . Strings::shift($response, $length);
return false;
@ -2619,6 +2640,7 @@ class SSH2
return false;
}
extract(unpack('Ctype', Strings::shift($response, 1)));
/** @var integer $type */
switch ($type) {
case NET_SSH2_MSG_USERAUTH_FAILURE:
@ -3240,6 +3262,10 @@ class SSH2
return false;
}
extract(unpack('Npacket_length/Cpadding_length', Strings::shift($raw, 5)));
/**
* @var integer $packet_length
* @var integer $padding_length
*/
$remaining_length = $packet_length + 4 - $this->decrypt_block_size;
@ -3322,6 +3348,11 @@ class SSH2
return false;
}
extract(unpack('Nreason_code/Nlength', Strings::shift($payload, 8)));
/**
* @var integer $reason_code
* @var integer $length
*/
$this->errors[] = 'SSH_MSG_DISCONNECT: ' . $this->disconnect_reasons[$reason_code] . "\r\n" . utf8_decode(Strings::shift($payload, $length));
$this->bitmap = 0;
return false;
@ -3334,6 +3365,8 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($payload, 4)));
/** @var integer $length */
$this->errors[] = 'SSH_MSG_DEBUG: ' . utf8_decode(Strings::shift($payload, $length));
$payload = $this->get_binary_packet($skip_channel_filter);
break;
@ -3356,6 +3389,8 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($payload, 4)));
/** @var integer $length */
$this->banner_message = utf8_decode(Strings::shift($payload, $length));
$payload = $this->get_binary_packet();
}
@ -3379,6 +3414,8 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($payload, 4)));
/** @var integer $length */
$this->errors[] = 'SSH_MSG_GLOBAL_REQUEST: ' . Strings::shift($payload, $length);
if (!$this->send_binary_packet(pack('C', NET_SSH2_MSG_REQUEST_FAILURE))) {
@ -3393,11 +3430,15 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($payload, 4)));
/** @var integer $length */
$data = Strings::shift($payload, $length);
if (strlen($payload) < 4) {
return false;
}
extract(unpack('Nserver_channel', Strings::shift($payload, 4)));
/** @var integer $server_channel */
switch ($data) {
case 'auth-agent':
case 'auth-agent@openssh.com':
@ -3408,7 +3449,9 @@ class SSH2
return false;
}
extract(unpack('Nremote_window_size', Strings::shift($payload, 4)));
/** @var integer $remote_window_size */
extract(unpack('Nremote_maximum_packet_size', Strings::shift($payload, 4)));
/** @var integer $remote_maximum_packet_size*/
$this->packet_size_client_to_server[$new_channel] = $remote_window_size;
$this->window_size_server_to_client[$new_channel] = $remote_maximum_packet_size;
@ -3457,7 +3500,9 @@ class SSH2
return false;
}
extract(unpack('Nchannel', Strings::shift($payload, 4)));
/** @var integer $channel */
extract(unpack('Nwindow_size', Strings::shift($payload, 4)));
/** @var integer $window_size */
$this->window_size_client_to_server[$channel]+= $window_size;
@ -3602,14 +3647,17 @@ class SSH2
return false;
}
extract(unpack('Ctype', Strings::shift($response, 1)));
/** @var integer $type */
if (strlen($response) < 4) {
return false;
}
if ($type == NET_SSH2_MSG_CHANNEL_OPEN) {
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
} else {
extract(unpack('Nchannel', Strings::shift($response, 4)));
/** @var integer $channel */
}
// will not be setup yet on incoming channel open request
@ -3636,6 +3684,10 @@ class SSH2
return false;
}
extract(unpack('Ndata_type_code/Nlength', Strings::shift($response, 8)));
/**
* @var integer $data_type_code
* @var integer $length
*/
$data = Strings::shift($response, $length);
$this->stdErrorLog.= $data;
if ($skip_extended || $this->quiet_mode) {
@ -3660,11 +3712,13 @@ class SSH2
return false;
}
extract(unpack('Nserver_channel', Strings::shift($response, 4)));
/** @var integer $server_channel */
$this->server_channels[$channel] = $server_channel;
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nwindow_size', Strings::shift($response, 4)));
/** @var integer $window_size */
if ($window_size < 0) {
$window_size&= 0x7FFFFFFF;
@ -3718,6 +3772,8 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$data = Strings::shift($response, $length);
if ($channel == self::CHANNEL_AGENT_FORWARD) {
@ -3741,6 +3797,8 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$value = Strings::shift($response, $length);
switch ($value) {
case 'exit-signal':
@ -3749,12 +3807,16 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
$this->errors[] = 'SSH_MSG_CHANNEL_REQUEST (exit-signal): ' . Strings::shift($response, $length);
if (strlen($response) < 4) {
return false;
}
Strings::shift($response, 1);
extract(unpack('Nlength', Strings::shift($response, 4)));
/** @var integer $length */
if ($length) {
$this->errors[count($this->errors)].= "\r\n" . Strings::shift($response, $length);
}
@ -3770,6 +3832,10 @@ class SSH2
return false;
}
extract(unpack('Cfalse/Nexit_status', Strings::shift($response, 5)));
/**
* @var integer $false
* @var integer $exit_status
*/
$this->exit_status = $exit_status;
@ -4385,6 +4451,8 @@ class SSH2
return false;
}
extract(unpack('Nlength', Strings::shift($server_public_host_key, 4)));
/** @var integer $length */
Strings::shift($server_public_host_key, $length);
if ($this->signature_validated) {