I've tested this on a different SFTP server and the problem doesn't exist.
It appears that the SFTP server our company is using has this bug.
Thanks for your help,
Bob
-----Original Message-----
From: libssh2-devel [mailto:libssh2-devel-bounces_at_cool.haxx.se] On Behalf Of
Daniel Stenberg
Sent: Wednesday, March 12, 2014 3:42 PM
To: libssh2 development
Subject: Re: SFTP read problems
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 _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-develReceived on 2014-03-17