cURL / Mailing Lists / curl-library / Single Mail


Curl and GXS SFTP

From: Marc Renault <>
Date: Thu, 11 Dec 2014 21:29:54 +0100


I'm running into the same problem as a couple of posts:

Like the previous posts I'm trying to connect to GXS (OpenText) SFTP server
with Curl and I've run into the same issue.

Based on the previous posts, I did some digging to see what is going on
with the libssh2_sftp_stat_ex call at ssh.c:2089. From what I can tell, the
call works fine. But the flags that are set are only:
That is the value of attrs.flags is 12.

Out of curiosity, I hacked libSSH2 and forced it to read a value for the
file size. With a value greater than the size of the file, the file is
downloaded which makes sense.

Essentially, the code handles the case where there server doesn't respond
to the SSH_FXP_STAT but doesn't consider the case that a server might
respond to SSH_FXP_STAT without a file size. My proposed fix is the

      else if(rc) {
         * libssh2_sftp_open() didn't return an error, so maybe the server
         * just doesn't support stat()
        data->req.size = -1;
        data->req.maxdownload = -1;
        Curl_pgrsSetDownloadSize(data, -1);
      else if(attrs.filesize == 0)
   * The server doesn't return a file size with a stat().
  data->req.size = -1;
  data->req.maxdownload = -1;
  Curl_pgrsSetDownloadSize(data, -1);
      else {

        curl_off_t size = attrs.filesize;

I tested it against the GXS SFTP server (with the unhacked libSSH2) and it
works. I'm not nearly familiar enough with the rest of the code to have any
idea if this would mess anything else up.

Marc Renault

List admin:
Received on 2014-12-11