Skip to content

Commit

Permalink
SSH2: suppress errors on stream_select calls
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Dec 23, 2020
1 parent 19afa63 commit 7a9418e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions phpseclib/Net/SSH2.php
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ private function connect()
$start = microtime(true);
$sec = floor($this->curTimeout);
$usec = 1000000 * ($this->curTimeout - $sec);
if (stream_select($read, $write, $except, $sec, $usec) === false) {
if (@stream_select($read, $write, $except, $sec, $usec) === false) {
$this->is_timeout = true;
return false;
}
Expand Down Expand Up @@ -3194,9 +3194,9 @@ private function get_binary_packet($skip_channel_filter = false)

if ($this->curTimeout <= 0) {
if ($this->keepAlive <= 0) {
stream_select($read, $write, $except, null);
@stream_select($read, $write, $except, null);
} else {
if (!stream_select($read, $write, $except, $this->keepAlive)) {
if (!@stream_select($read, $write, $except, $this->keepAlive)) {
$this->send_binary_packet(pack('CN', NET_SSH2_MSG_IGNORE, 0));
return $this->get_binary_packet(true);
}
Expand All @@ -3213,7 +3213,7 @@ private function get_binary_packet($skip_channel_filter = false)
$start = microtime(true);

if ($this->keepAlive > 0 && $this->keepAlive < $this->curTimeout) {
if (!stream_select($read, $write, $except, $this->keepAlive)) {
if (!@stream_select($read, $write, $except, $this->keepAlive)) {
$this->send_binary_packet(pack('CN', NET_SSH2_MSG_IGNORE, 0));
$elapsed = microtime(true) - $start;
$this->curTimeout-= $elapsed;
Expand All @@ -3226,8 +3226,8 @@ private function get_binary_packet($skip_channel_filter = false)
$sec = floor($this->curTimeout);
$usec = 1000000 * ($this->curTimeout - $sec);

// on windows this returns a "Warning: Invalid CRT parameters detected" error
if (!stream_select($read, $write, $except, $sec, $usec)) {
// this can return a "stream_select(): unable to select [4]: Interrupted system call" error
if (!@stream_select($read, $write, $except, $sec, $usec)) {
$this->is_timeout = true;
return true;
}
Expand Down

1 comment on commit 7a9418e

@terrafrost
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1560

Please sign in to comment.