We performed the investigation on this issue by using JSch-0.1.53.

In the Read process during the first data transmit ion, "buffer.buffe" will be 
the newly created (extended) reference by Packet.java::shift().

  byte[] foo=new byte[s+buffer.index-5-9-len];
  buffer.buffer=foo;


During the second data transmit ion where a reference will be different from 
"byte[] data" in ChennelSftp.java::_put(), if the input data read from the 47th 
byte of "data" by ChennelSftp.java::sendWRITE() is copied to "obuf" from the 
0th byte of it, the data will be different from the one which had been actually 
read.

* The first 47 bytes are forwarded to the SFTP server as invalid data.

  if(obuf.buffer!=data) 
    obuf.putString(data, start, _length);

* Normally, it is supposed to be a right action to start a copy from the 47th 
byte of "data".

So we have come up with the following two fixes, is our understanding of this 
issue correct? 

1. Make "byte[] data" be the same reference as "obuf.buffer" at the time before 
when the input file is read.

By adding the line "data=obuf.buffer;" to the 634th line in 
ChennelSftp.java::_put(), make "obuf.buffer" always be the same reference as 
"data".

2. Modify the third argument of ChennelSftp.java::sendWRITE() from "0" to "_s".

Modify the 668th line in ChennelSftp.java::_put(), that is 
"foo-=sendWRITE(handle, offset, data, 0, foo);", to "foo-=sendWRITE(handle, 
offset, data, _s, foo);".

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to