[JSch-users] Illegal data get mixed into a sent file
Status: Alpha
Brought to you by:
ymnk
From: Kagoshima D. A. Co., L. T.O. <ooh...@da...> - 2016-06-08 23:15:21
|
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);". |