Subject: Re: SFTP read problems

Re: SFTP read problems

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 12 Mar 2014 20:42:25 +0100 (CET)

On Sat, 8 Mar 2014, Bob Kast wrote:

> When doing a read a file that is about 12k, it fails partway through with
> LIBSSH2_ERROR_SFTP_PROTOCOL. In looking closer, it is at this point in
> sftp.c:
>
> if(rc32 > chunk->len) {
> /* A chunk larger than we requested was returned to us.
> This is a protocol violation and we don't know how to
> deal with it. Bail out! */
> return _libssh2_error(session,
> LIBSSH2_ERROR_SFTP_PROTOCOL,
> "FXP_READ response too big");
> }
>
> My code requests a block of 4096. It multiplies that by 4 (16,384), then it
> starts doing packets requesting 2000 characters. After it's done 8 of these,
> the 'count' goes down to 384, which is what chunk->len is set to above. rc32
> is set to 2000 so it fails.

I assume you're trying with the latest libssh2 version?

> I've found if I have the requested buffer at exactly a multiple of 2000, it
> seems to work, although I'm somewhat nervous about it working for all cases.
>
> Is this expected? It is not documented.

It is not expected. The check above is there to detect the error situation
when a server returns a bigger chunk than what we asked for.

libssh2 splits up data sizes into smaller chunks and ask for them one by one,
so chunk->len is supposed to be the size of the chunk it asked for.

-- 
  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2014-03-12