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

Archive Index This month's Index

Subject: SFTP read problems

SFTP read problems

From: Bob Kast <bob_2824_at_hotmail.com>
Date: Sat, 8 Mar 2014 08:35:51 -0500

I'm trying to use libssh2 (and openssl) for doing SFTP transfers on Windows
platforms (x64 and x86).

I got it all compiled (although the x64 compile puts out a lot of warnings -
I haven't looked at them all but they seem to be innocuous).

I have a problem in doing an SFTP read. I took the code from the examples
dir.

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

Thanks,
Bob
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2014-03-08

the libssh2 team