Skip to content

Commit

Permalink
CS adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Nov 22, 2023
1 parent cf1be6a commit 77b00c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
9 changes: 9 additions & 0 deletions phpseclib/Exception/OutOfBoundsException.php
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace phpseclib3\Exception;

class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface
{
}
3 changes: 2 additions & 1 deletion phpseclib/Math/BinaryField.php
Expand Up @@ -17,6 +17,7 @@
namespace phpseclib3\Math;

use phpseclib3\Common\Functions\Strings;
use phpseclib3\Exception\OutOfBoundsException;
use phpseclib3\Math\BinaryField\Integer;
use phpseclib3\Math\Common\FiniteField;

Expand Down Expand Up @@ -57,7 +58,7 @@ public function __construct(...$indices)
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
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';
foreach ($indices as $index) {
Expand Down
8 changes: 3 additions & 5 deletions phpseclib/Net/SSH2.php
Expand Up @@ -2066,7 +2066,7 @@ private function login_helper(string $username, $password = null): bool
[$type] = Strings::unpackSSH2('C', $response);

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++) {
[$extension_name, $extension_value] = Strings::unpackSSH2('ss', $response);
if ($extension_name == 'server-sig-algs') {
Expand All @@ -2075,12 +2075,10 @@ private function login_helper(string $username, $password = null): bool
}

$response = $this->get_binary_packet();
list($type) = Strings::unpackSSH2('C', $response);
[$type] = Strings::unpackSSH2('C', $response);
}

list($service) = Strings::unpackSSH2('s', $response);

[$type, $service] = Strings::unpackSSH2('Cs', $response);
[$service] = Strings::unpackSSH2('s', $response);
if ($type != MessageType::SERVICE_ACCEPT || $service != 'ssh-userauth') {
$this->disconnect_helper(DisconnectReason::PROTOCOL_ERROR);
throw new UnexpectedValueException('Expected SSH_MSG_SERVICE_ACCEPT');
Expand Down

0 comments on commit 77b00c3

Please sign in to comment.