diff --git a/src/Renci.SshNet/Abstractions/ThreadAbstraction.cs b/src/Renci.SshNet/Abstractions/ThreadAbstraction.cs index f1ed202ae..fe6e3e218 100644 --- a/src/Renci.SshNet/Abstractions/ThreadAbstraction.cs +++ b/src/Renci.SshNet/Abstractions/ThreadAbstraction.cs @@ -36,6 +36,8 @@ public static void ExecuteThreadLongRunning(Action action) /// The action to execute. public static void ExecuteThread(Action action) { + if (action == null) + throw new ArgumentNullException("action"); #if FEATURE_THREAD_THREADPOOL System.Threading.ThreadPool.QueueUserWorkItem(o => action()); #elif FEATURE_THREAD_TAP diff --git a/src/Renci.SshNet/Sftp/SftpFileStream.cs b/src/Renci.SshNet/Sftp/SftpFileStream.cs index 853010cb0..cc66677f5 100644 --- a/src/Renci.SshNet/Sftp/SftpFileStream.cs +++ b/src/Renci.SshNet/Sftp/SftpFileStream.cs @@ -362,7 +362,7 @@ public override int Read(byte[] buffer, int offset, int count) { // copy remaining bytes to read buffer _bufferLen = data.Length - bytesToWriteToCallerBuffer; - Buffer.BlockCopy(data, count, _readBuffer, 0, _bufferLen); + Buffer.BlockCopy(data, bytesToWriteToCallerBuffer, _readBuffer, 0, _bufferLen); } } else