mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-01 05:31:53 +00:00
Throw exception instead of triggering error, and added base exception interface
This commit is contained in:
parent
3f3de53503
commit
a8f30f516a
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class BadConfigurationException extends \RuntimeException
|
||||
class BadConfigurationException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class BadDecryptionException extends \RuntimeException
|
||||
class BadDecryptionException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class BadModeException extends \RuntimeException
|
||||
class BadModeException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class ConnectionClosedException extends \RuntimeException
|
||||
class ConnectionClosedException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
12
phpseclib/Exception/ExceptionInterface.php
Normal file
12
phpseclib/Exception/ExceptionInterface.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpseclib3\Exception;
|
||||
|
||||
/**
|
||||
* Used to mark exceptions originating from this library.
|
||||
*/
|
||||
interface ExceptionInterface
|
||||
{
|
||||
}
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class FileNotFoundException extends \RuntimeException
|
||||
class FileNotFoundException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class InconsistentSetupException extends \RuntimeException
|
||||
class InconsistentSetupException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class InsufficientSetupException extends \RuntimeException
|
||||
class InsufficientSetupException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class NoKeyLoadedException extends \RuntimeException
|
||||
class NoKeyLoadedException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class NoSupportedAlgorithmsException extends \RuntimeException
|
||||
class NoSupportedAlgorithmsException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
9
phpseclib/Exception/RuntimeException.php
Normal file
9
phpseclib/Exception/RuntimeException.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpseclib3\Exception;
|
||||
|
||||
class RuntimeException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class UnableToConnectException extends \RuntimeException
|
||||
class UnableToConnectException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class UnsupportedAlgorithmException extends \RuntimeException
|
||||
class UnsupportedAlgorithmException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class UnsupportedCurveException extends \RuntimeException
|
||||
class UnsupportedCurveException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class UnsupportedFormatException extends \RuntimeException
|
||||
class UnsupportedFormatException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
|
||||
*
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
class UnsupportedOperationException extends \RuntimeException
|
||||
class UnsupportedOperationException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ use phpseclib3\Crypt\Twofish;
|
||||
use phpseclib3\Exception\ConnectionClosedException;
|
||||
use phpseclib3\Exception\InsufficientSetupException;
|
||||
use phpseclib3\Exception\NoSupportedAlgorithmsException;
|
||||
use phpseclib3\Exception\RuntimeException;
|
||||
use phpseclib3\Exception\UnableToConnectException;
|
||||
use phpseclib3\Exception\UnsupportedAlgorithmException;
|
||||
use phpseclib3\Exception\UnsupportedCurveException;
|
||||
@ -3264,18 +3265,18 @@ class SSH2
|
||||
$cmf = ord($payload[0]);
|
||||
$cm = $cmf & 0x0F;
|
||||
if ($cm != 8) { // deflate
|
||||
trigger_error("Only CM = 8 ('deflate') is supported ($cm)");
|
||||
throw new UnsupportedAlgorithmException("Only CM = 8 ('deflate') is supported ($cm)");
|
||||
}
|
||||
$cinfo = ($cmf & 0xF0) >> 4;
|
||||
if ($cinfo > 7) {
|
||||
trigger_error("CINFO above 7 is not allowed ($cinfo)");
|
||||
throw new RuntimeException("CINFO above 7 is not allowed ($cinfo)");
|
||||
}
|
||||
$windowSize = 1 << ($cinfo + 8);
|
||||
|
||||
$flg = ord($payload[1]);
|
||||
//$fcheck = $flg && 0x0F;
|
||||
if ((($cmf << 8) | $flg) % 31) {
|
||||
trigger_error('fcheck failed');
|
||||
throw new RuntimeException('fcheck failed');
|
||||
}
|
||||
$fdict = boolval($flg & 0x20);
|
||||
$flevel = ($flg & 0xC0) >> 6;
|
||||
|
Loading…
Reference in New Issue
Block a user