1
0
mirror of https://github.com/danog/tgseclib.git synced 2024-11-30 04:39:02 +01:00

Merge pull request #1313 from sebsel/fix/user_error

fix order of user_error() and bitmap reset

* sebsel/fix/user_error:
  fix order of user_error() and bitmap reset
This commit is contained in:
Andreas Fischer 2018-11-11 16:23:36 +01:00
commit eb4ff2f6e1

View File

@ -3335,8 +3335,8 @@ class SSH2
function _get_binary_packet($skip_channel_filter = false) function _get_binary_packet($skip_channel_filter = false)
{ {
if (!is_resource($this->fsock) || feof($this->fsock)) { if (!is_resource($this->fsock) || feof($this->fsock)) {
user_error('Connection closed prematurely');
$this->bitmap = 0; $this->bitmap = 0;
user_error('Connection closed prematurely');
return false; return false;
} }
@ -3379,8 +3379,8 @@ class SSH2
while ($remaining_length > 0) { while ($remaining_length > 0) {
$temp = stream_get_contents($this->fsock, $remaining_length); $temp = stream_get_contents($this->fsock, $remaining_length);
if ($temp === false || feof($this->fsock)) { if ($temp === false || feof($this->fsock)) {
user_error('Error reading from socket');
$this->bitmap = 0; $this->bitmap = 0;
user_error('Error reading from socket');
return false; return false;
} }
$buffer.= $temp; $buffer.= $temp;
@ -3398,8 +3398,8 @@ class SSH2
if ($this->hmac_check !== false) { if ($this->hmac_check !== false) {
$hmac = stream_get_contents($this->fsock, $this->hmac_size); $hmac = stream_get_contents($this->fsock, $this->hmac_size);
if ($hmac === false || strlen($hmac) != $this->hmac_size) { if ($hmac === false || strlen($hmac) != $this->hmac_size) {
user_error('Error reading socket');
$this->bitmap = 0; $this->bitmap = 0;
user_error('Error reading socket');
return false; return false;
} elseif ($hmac != $this->hmac_check->hash(pack('NNCa*', $this->get_seq_no, $packet_length, $padding_length, $payload . $padding))) { } elseif ($hmac != $this->hmac_check->hash(pack('NNCa*', $this->get_seq_no, $packet_length, $padding_length, $payload . $padding))) {
user_error('Invalid HMAC'); user_error('Invalid HMAC');