cURL / Mailing Lists / curl-library / Single Mail

curl-library

Problems with SFTP upload

From: Andreas Wurf <awurf_at_adobe.com>
Date: Fri, 17 Oct 2008 10:33:16 +0100

Hi everyone,

I have a problem with libcurl/libssh2 SFTP file upload. Maybe this is better suited for the libssh2 mailing list, I don't know, please decide for yourself. I don't even know, if it's libcurl/libssh2-related at all ;-)

My application uploads a bunch of files to a server. Using plain FTP protocol works without any problems. Using SFTP, on *some transfers* (I can't say what's the trigger), The server creates the file (with 0 bytes in size) but on the client side I get an error message "Upload failed: Unknown error in libssh2". This happens on different files on approx. each 50th transfer and on release builds it is more reproducible than on debug builds (timing-related problem?).

I tried to track it down:

In libssh2_sftp_open_ex(), the following code is executed:

    if (data[0] == SSH_FXP_STATUS) {
        libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
                      "Failed opening remote file", 0);
        sftp->last_errno = libssh2_ntohu32(data + 5);
        LIBSSH2_FREE(session, data);
        return NULL;
    }

Here's a dump of "data":

        0x02A00F20 65 00 00 00 0e 00 00 00 00 00 00 00 07 53 75 63 e............Suc
        0x02A00F30 63 65 73 73 00 00 00 00 cd cd cd cd cd cd cd cd cess....ออออออออ

data[0] contains SSH_FXP_STATUS, so the if-block is entered. sftp->last_errno is set to zero, since this is the value from data[5]-data[8].

So, in essence, the following appears to happen: The client requests the file to be created on the server using libssh2_sftp_open_ex(). The server creates the file with 0 bytes size. Instead of returning a handle to the file, it sends a SH_FXP_STATUS with the result code 0 (Success). What the heck is this? Could this even be a problem related to the server?

My environment is:

        MS-Windows XP
        MS VisualStudio 2005
        libcurl 7.19.0
        libssh2 0.19.0_CVS as of 10-10-2008
        c-ares 1.5.2
        ...

Any help is very much appreciated.

Cheers,
Andreas
Received on 2008-10-17