Subject: Re: libssh2_sftp_seek64 doesn't work

Re: libssh2_sftp_seek64 doesn't work

From: m odd <>
Date: Wed, 24 Aug 2011 11:24:46 +0800

    /* We allow a number of bytes being requested at any given time without
       having been acked - until we reach EOF. */
    if(!filep->eof) {
        /* if the buffer_size passed in now is smaller than what has already
           been sent, we risk getting count become a very large number */
        if((buffer_size*4) > already)
            count = (buffer_size*4) - already;

In the sftp_read(), the actually request count is bigger than
buffer_size,so, the previous call will get more data than you want.
I think libssh2_sftp_seek64() must discard the unnecessary request packet
and the data already stored.

libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset)
    if(handle) {
        handle->u.file.offset = handle->u.file.offset_sent = offset;
        if (handle->u.file.data_left) {

 LIBSSH2_FREE(handle->sftp->channel->session, handle->;
            handle->u.file.data_left = handle->u.file.data_len = 0;
            handle-> = NULL;

Received on 2011-08-24