★ wanayoo — archive 1999 https://github.com/sshnet/SSH.NET/issues/453Nouvelle recherche | Portail wanayoo
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

Race Condition in ShellStream causing NullReferenceException #453

Open
keithallenjackson opened this issue Aug 2, 2018 · 0 comments
Open

Race Condition in ShellStream causing NullReferenceException #453

keithallenjackson opened this issue Aug 2, 2018 · 0 comments
Milestone

Comments

@keithallenjackson
Copy link

@keithallenjackson keithallenjackson commented Aug 2, 2018

Issue:
Race condition in ShellStream occurs when underlying connection abruptly disconnects. The disconnect causes the stream to dispose. The Expect(Regex, TimeSpan) method utilizes an AutoResetEvent used to synchronize when new data is received, but the AutoResetEvent is disposed of and set to null.

Fix:
Do not dispose of an object that could be in use by another thread. In this particular context, the Producer (underlying connection) has abruptly finished, so the ShellStream would need have a state that reflects this. Any methods that utilize the existing (and only remaining) data, should not wait for more data to arrive and either return null (such as Expect) immediately, or throw SshConnectionException. The Consumer (user of the API) should be the one that disposes.

keithallenjackson pushed a commit to keithallenjackson/SSH.NET that referenced this issue Aug 18, 2018
+ ShellStream.Expect no longer throws NullReferenceException when channel unexpectedly disconnects.
+ Adds Disconnect event to ShellStream.
+ Adds Disposed property to ShellStream to read internal disposed state.
@drieseng drieseng added this to the 2020.0.0-beta2 milestone Jun 28, 2020
@drieseng drieseng modified the milestones: 2020.0.0, 2020.1.0 Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.