Closed GoogleCodeExporter closed 8 years ago
I don't understand why this is incorrect.
Original comment by dkocher@sudo.ch
on 8 Apr 2014 at 11:44
Original comment by dkocher@sudo.ch
on 9 Apr 2014 at 1:12
Sorry if I didn't clarify enough.
The bug is subtle and difficult to recognize with the eye, given that the exact
same sequence of lines is correct in line 112 in the other read(...) method
(the one with signature read(byte[], int, int)).
But, in the read() method without arguments, the value returned by the call to
super.read() (in line 81, [1]) is _not_ the _number_ of bytes read, but the
_value_ of the last read byte, as per definition of read (see [2]). It is thus
an error to subtract that value from the number of remaining bytes, since the
number of remaing bytes has only decreased by 1 (at max).
At the company I work for we use a workaround for this bug (only use the
read(byte[]) variant).
Hope I made it clearer this time.
[1]
https://code.google.com/p/ganymed-ssh-2/source/browse/trunk/src/main/java/ch/eth
z/ssh2/SCPInputStream.java#81
[2] http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html#read()
Original comment by jonas.es...@googlemail.com
on 10 Apr 2014 at 8:56
Thanks for the clarification. Fix in r103.
Original comment by dkocher@sudo.ch
on 10 Apr 2014 at 1:58
Original issue reported on code.google.com by
jonas.es...@googlemail.com
on 11 Mar 2014 at 2:39