cURL / Mailing Lists / curl-library / Single Mail

curl-library

Curl and GXS SFTP

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

Hi,

I'm running into the same problem as a couple of posts:
http://curl.haxx.se/mail/lib-2014-09/0199.html
http://curl.haxx.se/mail/lib-2012-06/0156.html
http://curl.haxx.se/mail/lib-2012-03/0245.html
http://curl.haxx.se/mail/archive-2009-01/0114.html

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:
SSH_FILEXFER_ATTR_PERMISSIONS 0x00000004
SSH_FILEXFER_ATTR_ACCESSTIME 0x00000008
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
following:

//ssh.c:2095
      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);
      }
//PROPOSE FIX
      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);
}
//END OF FIX
      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.

Thanks,
Marc Renault

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-12-11