mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-28 12:10:59 +00:00
replace user_error with exceptions in a few more places
This commit is contained in:
parent
0571ab0e0c
commit
56a644faa8
@ -2533,8 +2533,8 @@ class SFTP extends SSH2
|
|||||||
case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
|
case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS');
|
throw new \UnexpectedValueException('Expected NET_SFTP_HANDLE or NET_SFTP_STATUS. '
|
||||||
return false;
|
. 'Got packet type: ' . $this->packet_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1608,14 +1608,12 @@ class SSH2
|
|||||||
|
|
||||||
$response = $this->get_binary_packet();
|
$response = $this->get_binary_packet();
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
user_error('Connection closed by server');
|
throw new \RuntimeException('Connection closed by server');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
extract(unpack('Ctype', Strings::shift($response, 1)));
|
extract(unpack('Ctype', Strings::shift($response, 1)));
|
||||||
/** @var integer $type */
|
/** @var integer $type */
|
||||||
if ($type != NET_SSH2_MSG_KEXDH_GEX_GROUP) {
|
if ($type != NET_SSH2_MSG_KEXDH_GEX_GROUP) {
|
||||||
user_error('Expected SSH_MSG_KEX_DH_GEX_GROUP');
|
throw new \RuntimeException('Expected SSH_MSG_KEX_DH_GEX_GROUP');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($response) < 4) {
|
if (strlen($response) < 4) {
|
||||||
@ -1751,7 +1749,7 @@ class SSH2
|
|||||||
|
|
||||||
if ($kex_algorithm === 'curve25519-sha256@libssh.org') {
|
if ($kex_algorithm === 'curve25519-sha256@libssh.org') {
|
||||||
if (strlen($fBytes) !== 32) {
|
if (strlen($fBytes) !== 32) {
|
||||||
user_error('Received curve25519 public key of invalid length.');
|
throw new \RuntimeException('Received curve25519 public key of invalid length.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$key = new BigInteger(\Sodium\crypto_scalarmult($x, $fBytes), 256);
|
$key = new BigInteger(\Sodium\crypto_scalarmult($x, $fBytes), 256);
|
||||||
@ -2701,8 +2699,7 @@ class SSH2
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->in_request_pty_exec) {
|
if ($this->in_request_pty_exec) {
|
||||||
user_error('If you want to run multiple exec()\'s you will need to disable (and re-enable if appropriate) a PTY for each one.');
|
throw new \RuntimeException('If you want to run multiple exec()\'s you will need to disable (and re-enable if appropriate) a PTY for each one.');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RFC4254 defines the (client) window size as "bytes the other party can send before it must wait for the window to
|
// RFC4254 defines the (client) window size as "bytes the other party can send before it must wait for the window to
|
||||||
|
Loading…
Reference in New Issue
Block a user