Skip to content

Commit

Permalink
Merge branch '1.0' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed May 19, 2024
2 parents 1fc0ad1 + 62352f4 commit a134f1c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions phpseclib/Net/SSH2.php
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ class SSH2
* @var bool
* @access private
*/
var $retry_connect = false;
var $login_credentials_finalized = false;

/**
* Binary Packet Buffer
Expand Down Expand Up @@ -2292,7 +2292,7 @@ function _bad_algorithm_candidate($algorithm)
function login($username)
{
$args = func_get_args();
if (!$this->retry_connect) {
if (!$this->login_credentials_finalized) {
$this->auth[] = $args;
}

Expand Down Expand Up @@ -2383,6 +2383,7 @@ function _login($username)

foreach ($newargs as $arg) {
if ($this->_login_helper($username, $arg)) {
$this->login_credentials_finalized = true;
return true;
}
}
Expand Down Expand Up @@ -2418,10 +2419,14 @@ function _login_helper($username, $password = null)
return false;
}

$bad_key_size_fix = $this->bad_key_size_fix;
$response = $this->_get_binary_packet();
if ($response === false) {
if ($this->retry_connect) {
$this->retry_connect = false;
// bad_key_size_fix is only ever re-assigned to true
// under certain conditions. when it's newly set we'll
// retry the connection with that new setting but we'll
// only try it once.
if ($bad_key_size_fix != $this->bad_key_size_fix) {
if (!$this->_connect()) {
return false;
}
Expand Down Expand Up @@ -3553,7 +3558,6 @@ function ping()
function _reconnect()
{
$this->_reset_connection(NET_SSH2_DISCONNECT_CONNECTION_LOST);
$this->retry_connect = true;
if (!$this->_connect()) {
return false;
}
Expand All @@ -3577,7 +3581,6 @@ function _reset_connection($reason)
$this->hmac_check = $this->hmac_create = false;
$this->hmac_size = false;
$this->session_id = false;
$this->retry_connect = true;
$this->get_seq_no = $this->send_seq_no = 0;
}

Expand Down

0 comments on commit a134f1c

Please sign in to comment.