Subject: RE: SFTP read problems

RE: SFTP read problems

From: Bob Kast <>
Date: Thu, 13 Mar 2014 08:36:48 -0400

> > 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.

I spent some time debugging it and at this point it does look like a
server-side issue.
I also tested the x86 version, thinking that there was a chance that the x64
compile may have introduced a bug but it behaves the same.
By specifying a multiple of 2000 byte buffer it never asks (so far, at
least) for a partial buffer and gets around the problem.


Received on 2014-03-13