Only write to the read buffer if we actually received data.

This commit is contained in:
Gert Driesen
2017-02-19 10:30:40 +01:00
parent 391a41c35d
commit 4e2bd63660
+2 -2
View File
@@ -337,14 +337,14 @@ namespace Renci.SshNet.Sftp
var data = _session.RequestRead(_handle, (ulong)_position, (uint)_readBufferSize);
_bufferLen = data.Length;
Buffer.BlockCopy(data, 0, _readBuffer, 0, _bufferLen);
_serverFilePosition = (ulong)_position;
if (_bufferLen == 0)
{
break;
}
Buffer.BlockCopy(data, 0, _readBuffer, 0, _bufferLen);
tempLen = _bufferLen;
}