Skip to content

Commit

Permalink
SSH2: don't count len of packets sent / rcvd during key exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Nov 22, 2024
1 parent ccf4b48 commit b38e849
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions phpseclib/Net/SSH2.php
Original file line number Diff line number Diff line change
Expand Up @@ -3749,7 +3749,9 @@ function _get_binary_packet($skip_channel_filter = false)

$remaining_length = $packet_length + 4 - $this->decrypt_block_size;

$this->bytesTransferredSinceLastKEX+= $packet_length + $padding_length + 5;
if (!$this->keyExchangeInProgress) {
$this->bytesTransferredSinceLastKEX+= $packet_length + $padding_length + 5;
}

// quoting <http://tools.ietf.org/html/rfc4253#section-6.1>,
// "implementations SHOULD check that the packet length is reasonable"
Expand Down Expand Up @@ -4468,7 +4470,9 @@ function _send_binary_packet($data, $logged = null)

$packet.= $hmac;

$this->bytesTransferredSinceLastKEX+= strlen($packet);
if (!$this->keyExchangeInProgress) {
$this->bytesTransferredSinceLastKEX+= strlen($packet);
}

$start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838
$result = strlen($packet) == @fputs($this->fsock, $packet);
Expand Down

0 comments on commit b38e849

Please sign in to comment.