I believe I have found a bug in the SCP.cs code
In the SCP_receiveFile method, there is a loop that does
int len = server.Read(buf, 0, foo);
where foo is either the length of the buffer (1024) or the remaining bytes of the file.
The remaining code in the loop assumes that len will alwyas be equal to foo which in some network latency cases, this is not true.
So instead of subtracting foo from the filesize and also in the fos.Write(...) call, len should be used instead of foo
I also found this, which was corrupting certain files. Changed the related procedure as follows:
/// Transfer a file from the remote server
/// <param name="server">A connected server I/O stream</param>
/// <param name="rfile">The remote file to copy</param>
/// <param name="lfile">The local destination path</param>
protected void SCP_ReceiveFile(Stream server, string rfile, string lfile, int size)
int copied = 0;
SendStartMessage(rfile, lfile, size, "Connected, starting transfer.");
// read a content of lfile
byte buf = new byte;
int bufferLength = buf.Length;
if (bufferLength > filesize)
bufferLength = filesize;
int len=server.Read(buf, 0, bufferLength);
copied += len;
fos.Write(buf, 0, len);
SendProgressMessage(rfile, lfile, copied, size, "Transferring...");
SendEndMessage(rfile, lfile, copied, size, "Transfer completed successfully ("+filesize+" bytes).");
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.