Skip to content

Race Condition in ShellStream causing NullReferenceException #453

Closed
@keithallenjackson

Description

@keithallenjackson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions