mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-14 17:34:07 +00:00
fix bad merge
This commit is contained in:
parent
0dbbeb39ce
commit
defd5d23b1
@ -128,12 +128,12 @@ abstract class Strings
|
|||||||
// 64-bit floats can be used to get larger numbers then 32-bit signed ints would allow
|
// 64-bit floats can be used to get larger numbers then 32-bit signed ints would allow
|
||||||
// for. sure, you're not gonna get the full precision of 64-bit numbers but just because
|
// for. sure, you're not gonna get the full precision of 64-bit numbers but just because
|
||||||
// you need > 32-bit precision doesn't mean you need the full 64-bit precision
|
// you need > 32-bit precision doesn't mean you need the full 64-bit precision
|
||||||
list(, $upper, $lower) = unpack('NN', self::shift($data, 8));
|
extract(unpack('Nupper/Nlower', self::shift($data, 8)));
|
||||||
$temp = $upper ? 4294967296 * $lower : 0;
|
$temp = $upper ? 4294967296 * $upper : 0;
|
||||||
$temp+= $lower < 0 ? ($temp & 0x7FFFFFFFF) + 0x80000000 : $temp;
|
$temp+= $lower < 0 ? ($lower & 0x7FFFFFFFF) + 0x80000000 : $lower;
|
||||||
// $temp = hexdec(bin2hex(self::shift($data, 8)));
|
// $temp = hexdec(bin2hex(self::shift($data, 8)));
|
||||||
$result[] = $temp;
|
$result[] = $temp;
|
||||||
continue;
|
continue 2;
|
||||||
}
|
}
|
||||||
list(, $length) = unpack('N', self::shift($data, 4));
|
list(, $length) = unpack('N', self::shift($data, 4));
|
||||||
if (strlen($data) < $length) {
|
if (strlen($data) < $length) {
|
||||||
@ -186,7 +186,7 @@ abstract class Strings
|
|||||||
$result.= $element ? "\1" : "\0";
|
$result.= $element ? "\1" : "\0";
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
case 'Q':
|
||||||
if (!is_int($element) || !is_float($element)) {
|
if (!is_int($element) && !is_float($element)) {
|
||||||
throw new \InvalidArgumentException('An integer was expected.');
|
throw new \InvalidArgumentException('An integer was expected.');
|
||||||
}
|
}
|
||||||
// 4294967296 == 1 << 32
|
// 4294967296 == 1 << 32
|
||||||
|
@ -666,10 +666,8 @@ class SFTP extends SSH2
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->version = (int) $ver;
|
$this->version = (int) $ver;
|
||||||
$packet = Strings::packSSH2('ss', 'version-select', $ver);
|
$packet = Strings::packSSH2('ss', 'version-select', "$ver");
|
||||||
if (!$this->send_sftp_packet(NET_SFTP_EXTENDED, $packet)) {
|
$this->send_sftp_packet(NET_SFTP_EXTENDED, $packet);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$response = $this->get_sftp_packet();
|
$response = $this->get_sftp_packet();
|
||||||
if ($this->packet_type != NET_SFTP_STATUS) {
|
if ($this->packet_type != NET_SFTP_STATUS) {
|
||||||
throw new \UnexpectedValueException('Expected NET_SFTP_STATUS. '
|
throw new \UnexpectedValueException('Expected NET_SFTP_STATUS. '
|
||||||
@ -699,11 +697,11 @@ class SFTP extends SSH2
|
|||||||
unset($this->extensions['newline@vandyke.com']);
|
unset($this->extensions['newline@vandyke.com']);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($this->version < 2 || $this->version > 6) {
|
if ($this->version < 2 || $this->version > 6) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->pwd = true;
|
||||||
$this->pwd = $this->realpath('.');
|
$this->pwd = $this->realpath('.');
|
||||||
|
|
||||||
$this->update_stat_cache($this->pwd, []);
|
$this->update_stat_cache($this->pwd, []);
|
||||||
@ -836,7 +834,7 @@ class SFTP extends SSH2
|
|||||||
*/
|
*/
|
||||||
public function realpath($path)
|
public function realpath($path)
|
||||||
{
|
{
|
||||||
if (!$this->precheck()) {
|
if ($this->precheck() === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -844,7 +842,7 @@ class SFTP extends SSH2
|
|||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->pwd === false) {
|
if ($this->pwd === true) {
|
||||||
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.9
|
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.9
|
||||||
$this->send_sftp_packet(NET_SFTP_REALPATH, Strings::packSSH2('s', $path));
|
$this->send_sftp_packet(NET_SFTP_REALPATH, Strings::packSSH2('s', $path));
|
||||||
|
|
||||||
@ -1508,7 +1506,7 @@ class SFTP extends SSH2
|
|||||||
*/
|
*/
|
||||||
public function truncate($filename, $new_size)
|
public function truncate($filename, $new_size)
|
||||||
{
|
{
|
||||||
$attr = Strings::packSSH2('Q', NET_SFTP_ATTR_SIZE, $new_size);
|
$attr = Strings::packSSH2('NQ', NET_SFTP_ATTR_SIZE, $new_size);
|
||||||
|
|
||||||
return $this->setstat($filename, $attr, false);
|
return $this->setstat($filename, $attr, false);
|
||||||
}
|
}
|
||||||
@ -1613,7 +1611,7 @@ class SFTP extends SSH2
|
|||||||
// "If either the owner or group field is zero length, the field should be
|
// "If either the owner or group field is zero length, the field should be
|
||||||
// considered absent, and no change should be made to that specific field
|
// considered absent, and no change should be made to that specific field
|
||||||
// during a modification operation"
|
// during a modification operation"
|
||||||
pack('NNa*Na*', NET_SFTP_ATTR_OWNERGROUP, strlen($uid), $uid, 0, '');
|
Strings::packSSH2('Nss', NET_SFTP_ATTR_OWNERGROUP, $uid, '');
|
||||||
|
|
||||||
return $this->setstat($filename, $attr, $recursive);
|
return $this->setstat($filename, $attr, $recursive);
|
||||||
}
|
}
|
||||||
@ -1638,7 +1636,7 @@ class SFTP extends SSH2
|
|||||||
{
|
{
|
||||||
$attr = $this->version < 4 ?
|
$attr = $this->version < 4 ?
|
||||||
pack('N3', NET_SFTP_ATTR_UIDGID, $gid, -1) :
|
pack('N3', NET_SFTP_ATTR_UIDGID, $gid, -1) :
|
||||||
pack('NNa*Na*', NET_SFTP_ATTR_OWNERGROUP, 0, '', strlen($gid), $gid);
|
Strings::packSSH2('Nss', NET_SFTP_ATTR_OWNERGROUP, '', $gid);
|
||||||
|
|
||||||
return $this->setstat($filename, $attr, $recursive);
|
return $this->setstat($filename, $attr, $recursive);
|
||||||
}
|
}
|
||||||
@ -1723,7 +1721,7 @@ class SFTP extends SSH2
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
$packet = Strings:packSSH2('s', $filename);
|
$packet = Strings::packSSH2('s', $filename);
|
||||||
$packet.= $this->version >= 4 ?
|
$packet.= $this->version >= 4 ?
|
||||||
pack('a*Ca*', substr($attr, 0, 4), NET_SFTP_TYPE_UNKNOWN, substr($attr, 4)) :
|
pack('a*Ca*', substr($attr, 0, 4), NET_SFTP_TYPE_UNKNOWN, substr($attr, 4)) :
|
||||||
$attr;
|
$attr;
|
||||||
@ -1915,8 +1913,8 @@ class SFTP extends SSH2
|
|||||||
string targetpath
|
string targetpath
|
||||||
string linkpath */
|
string linkpath */
|
||||||
$packet = substr($this->server_identifier, 0, 15) == 'SSH-2.0-OpenSSH' ?
|
$packet = substr($this->server_identifier, 0, 15) == 'SSH-2.0-OpenSSH' ?
|
||||||
Strings::packSSH2('SS', $target, $link) :
|
Strings::packSSH2('ss', $target, $link) :
|
||||||
Strings::packSSH2('SS', $link, $target);
|
Strings::packSSH2('ss', $link, $target);
|
||||||
}
|
}
|
||||||
$this->send_sftp_packet($type, $packet);
|
$this->send_sftp_packet($type, $packet);
|
||||||
|
|
||||||
@ -2133,7 +2131,7 @@ class SFTP extends SSH2
|
|||||||
|
|
||||||
$this->remove_from_stat_cache($remote_file);
|
$this->remove_from_stat_cache($remote_file);
|
||||||
|
|
||||||
$packet = Strings::packSSH2('s', $remote_filename);
|
$packet = Strings::packSSH2('s', $remote_file);
|
||||||
$packet.= $this->version >= 5 ?
|
$packet.= $this->version >= 5 ?
|
||||||
pack('N3', 0, $flags, 0) :
|
pack('N3', 0, $flags, 0) :
|
||||||
pack('N2', $flags, 0);
|
pack('N2', $flags, 0);
|
||||||
@ -3058,7 +3056,7 @@ class SFTP extends SSH2
|
|||||||
case NET_SFTP_ATTR_PERMISSIONS: // 0x00000004
|
case NET_SFTP_ATTR_PERMISSIONS: // 0x00000004
|
||||||
list($attr['mode']) = Strings::unpackSSH2('N', $response);
|
list($attr['mode']) = Strings::unpackSSH2('N', $response);
|
||||||
$fileType = $this->parseMode($attr['mode']);
|
$fileType = $this->parseMode($attr['mode']);
|
||||||
if ($version < 4 && $fileType !== false) {
|
if ($this->version < 4 && $fileType !== false) {
|
||||||
$attr+= ['type' => $fileType];
|
$attr+= ['type' => $fileType];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -216,7 +216,7 @@ class SSH2
|
|||||||
* @var array|false
|
* @var array|false
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private $server_identifier = false;
|
protected $server_identifier = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key Exchange Algorithms
|
* Key Exchange Algorithms
|
||||||
|
Loading…
Reference in New Issue
Block a user