diff --git a/src/Renci.SshNet/Common/PipeStream.cs b/src/Renci.SshNet/Common/PipeStream.cs index fac54fb62..9db0dbb92 100644 --- a/src/Renci.SshNet/Common/PipeStream.cs +++ b/src/Renci.SshNet/Common/PipeStream.cs @@ -180,8 +180,6 @@ public override void SetLength(long value) ///offset or count is negative. public override int Read(byte[] buffer, int offset, int count) { - if (offset != 0) - throw new NotSupportedException("Offsets with value of non-zero are not supported"); if (buffer == null) throw new ArgumentNullException("buffer"); if (offset + count > buffer.Length) @@ -213,7 +211,7 @@ public override int Read(byte[] buffer, int offset, int count) // fill the read buffer for (; readLength < count && _buffer.Count > 0; readLength++) { - buffer[readLength] = _buffer.Dequeue(); + buffer[readLength + offset] = _buffer.Dequeue(); } Monitor.Pulse(_buffer); @@ -230,7 +228,7 @@ public override int Read(byte[] buffer, int offset, int count) private bool ReadAvailable(int count) { var length = Length; - return (_isFlushed || length >= count) && (length >= (count + 1) || !BlockLastReadBuffer); + return (_isFlushed || length > 0) && (length >= (count + 1) || !BlockLastReadBuffer); } /// diff --git a/src/Renci.SshNet/Shell.cs b/src/Renci.SshNet/Shell.cs index c508be896..aba9262cb 100644 --- a/src/Renci.SshNet/Shell.cs +++ b/src/Renci.SshNet/Shell.cs @@ -166,7 +166,7 @@ public void Start() } finally { - _dataReaderTaskCompleted.Set(); + _dataReaderTaskCompleted?.Set(); } });