CS adjustment

This commit is contained in:
terrafrost 2023-11-22 04:58:39 -06:00
parent cf1be6a3d3
commit 77b00c3169
3 changed files with 14 additions and 6 deletions

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace phpseclib3\Exception;
class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface
{
}

View File

@ -17,6 +17,7 @@ declare(strict_types=1);
namespace phpseclib3\Math; namespace phpseclib3\Math;
use phpseclib3\Common\Functions\Strings; use phpseclib3\Common\Functions\Strings;
use phpseclib3\Exception\OutOfBoundsException;
use phpseclib3\Math\BinaryField\Integer; use phpseclib3\Math\BinaryField\Integer;
use phpseclib3\Math\Common\FiniteField; use phpseclib3\Math\Common\FiniteField;
@ -57,7 +58,7 @@ class BinaryField extends FiniteField
http://tools.ietf.org/html/rfc4253#section-6.1 (The Secure Shell (SSH) Transport Layer Protocol) says http://tools.ietf.org/html/rfc4253#section-6.1 (The Secure Shell (SSH) Transport Layer Protocol) says
"implementations SHOULD check that the packet length is reasonable in order for the implementation to "implementations SHOULD check that the packet length is reasonable in order for the implementation to
avoid denial of service and/or buffer overflow attacks" */ avoid denial of service and/or buffer overflow attacks" */
throw new \OutOfBoundsException('Degrees larger than 571 are not supported'); throw new OutOfBoundsException('Degrees larger than 571 are not supported');
} }
$val = str_repeat('0', $m) . '1'; $val = str_repeat('0', $m) . '1';
foreach ($indices as $index) { foreach ($indices as $index) {

View File

@ -2066,7 +2066,7 @@ class SSH2
[$type] = Strings::unpackSSH2('C', $response); [$type] = Strings::unpackSSH2('C', $response);
if ($type == MessageType::EXT_INFO) { if ($type == MessageType::EXT_INFO) {
list($nr_extensions) = Strings::unpackSSH2('N', $response); [$nr_extensions] = Strings::unpackSSH2('N', $response);
for ($i = 0; $i < $nr_extensions; $i++) { for ($i = 0; $i < $nr_extensions; $i++) {
[$extension_name, $extension_value] = Strings::unpackSSH2('ss', $response); [$extension_name, $extension_value] = Strings::unpackSSH2('ss', $response);
if ($extension_name == 'server-sig-algs') { if ($extension_name == 'server-sig-algs') {
@ -2075,12 +2075,10 @@ class SSH2
} }
$response = $this->get_binary_packet(); $response = $this->get_binary_packet();
list($type) = Strings::unpackSSH2('C', $response); [$type] = Strings::unpackSSH2('C', $response);
} }
list($service) = Strings::unpackSSH2('s', $response); [$service] = Strings::unpackSSH2('s', $response);
[$type, $service] = Strings::unpackSSH2('Cs', $response);
if ($type != MessageType::SERVICE_ACCEPT || $service != 'ssh-userauth') { if ($type != MessageType::SERVICE_ACCEPT || $service != 'ssh-userauth') {
$this->disconnect_helper(DisconnectReason::PROTOCOL_ERROR); $this->disconnect_helper(DisconnectReason::PROTOCOL_ERROR);
throw new UnexpectedValueException('Expected SSH_MSG_SERVICE_ACCEPT'); throw new UnexpectedValueException('Expected SSH_MSG_SERVICE_ACCEPT');