Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH2: Defer to default socket timeout in absence of more specific value #2023

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

rposky
Copy link
Contributor

@rposky rposky commented Aug 1, 2024

Attempting to address #2020, this issue formalizes the implied behavior prior to #1999 regarding PHP stream timeouts, by defaulting to PHP's default_socket_timeout for stream read functions when the user has not requested a timeout or keep-alive interval. This change mirrors the default timeout behavior of PHP socket streams, as evidenced here, and thus the behavior prior to #1999 changes, when stream_set_timeout was conditionally invoked. It is noteworthy that the prior implementation would not permit an update to remove a timeout via SSH2:setTimeout, given the conditional invocation of stream_set_timeout, now supported.

The following simple test confirms the underlying use of the default socket timeout when stream_set_timeout is never invoked, as execution terminates after 10 seconds, as defined.

<?php
$start = time();
ini_set('default_socket_timeout', 10);
$fsock = fsockopen('127.0.0.1', 22);
stream_get_contents($fsock);
printf("Time: %d", (time() - $start));

@terrafrost terrafrost merged commit 47895e2 into phpseclib:3.0 Aug 5, 2024
36 of 37 checks passed
@terrafrost
Copy link
Member

Looks good!

Also, apologies for the delay - I'm once again on vacation lol. I'm doing Black Hat USA in Vegas this week but left a few days early to do sight seeing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants