-
Notifications
You must be signed in to change notification settings - Fork 63
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
Endless loop in "_handle_control_chars()" if server sends EOF with zero bytes and endless loop in "channel_authenticate_telnet" in "async_channel.py" with same reason #142
Comments
Oh, and i see "sync_channel.py" must be fixed as well. |
Hey @davaeron thanks for opening this! I see there is a PR as well but will just respond here and we can sort stuff out and then get things merged as needed.
I was able to sorta recreate this by never returning from the If we get an EOF here then I assume we should be raising
Thoughts?
I dont believe this is actually an issue -- the Carl |
I think that
will fix all problems. |
Cool, will push that up to develop shortly. Thanks for opening this and for the help!! Carl |
Thank you for the help! |
Describe the bug
Bug in asynctelnet.
Code never returns from "open()" if server sends EOF.
When you connect to telnet server that sends EOFs, your code gets stuck in the endless loop in "_handle_control_chars()", because asyncio.StreamReader.read(1) will return an empty bytes object if EOF was received and the internal buffer is empty.
Here is a problem lines in "transport.py":
scrapli/scrapli/transport/plugins/asynctelnet/transport.py
Lines 127 to 133 in 062a5f4
This can be easly fixed with
after the line number 129,
but there is another problem just right after that one - with authentication in "channel_authenticate_telnet" in "async_channel.py"
scrapli/scrapli/channel/async_channel.py
Lines 329 to 339 in 062a5f4
I see increments in "return_attempts" but there is no limit for them. And it never stops.
I think we need to add some variable like "max_auth_return_retry" in "BaseChannelArgs".
And when return_attempts >= max_auth_return_retry - raise ScrapliAuthenticationFailed.
To Reproduce
Steps to reproduce the behavior:
pip install scrapli==2021.7.30a3
D-Link DES-1210-28/ME.
Expected behavior
Code returns from "open()" if server sends EOFs with ScrapliAuthenticationFailed.
Screenshots
OS (please complete the following information):
Additional context
I need some guidance on how to implement limiting function for "return_attempts" in "channel_authenticate_telnet" in "async_channel.py".
The text was updated successfully, but these errors were encountered: