Ticket #126 (closed defect: fixed)
_libssh2_channel_write returns erroneous value
|Reported by:||dseanrussell||Owned by:||bagder|
_libssh2_channel_write is not returning correct data under the following circumstances:
- buflen is larger than the current local window size, so channel->write_bufwrite is reduced to channel->local.window_size.
- The first chunk of the block is successfully written, so buflen, buf, and channel->write_bufwrote are updated correctly.
- When the second chunk of the block is to be written, there is apparenly new room in the local window, so the new data is copied to the packet and _libssh2_transport_write is called.
- _libssh2_transport_write fails with PACKET_EAGAIN, which is returned.
- The write is retried, and finally succeeds. The 'wrote' value is returned, which only contains the amount of the second chunk of the original write.
I believe that this function should return channel->write_bufwrote, not wrote.