www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: RE: SFTP read problems

RE: SFTP read problems

From: Bob Kast <bob_2824_at_hotmail.com>
Date: Mon, 17 Mar 2014 11:49:57 -0400

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,

-----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
> deal with it. Bail out! */
> return _libssh2_error(session,
> "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-devel
Received on 2014-03-17

the libssh2 team