]> granicus.if.org Git - curl/commitdiff
SFTP: work-around servers that return zero size on STAT
authorDaniel Stenberg <daniel@haxx.se>
Mon, 15 Dec 2014 21:52:30 +0000 (22:52 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 16 Dec 2014 08:49:17 +0000 (09:49 +0100)
Bug: http://curl.haxx.se/mail/lib-2014-12/0103.html
Pathed-by: Marc Renault
lib/ssh.c

index ba26eef72eee6a73cf24fe48cdbcf37126bce84f..d7e88c6f76af49560e2f1952af730891fa739c45 100644 (file)
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -2107,10 +2107,14 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
       if(rc == LIBSSH2_ERROR_EAGAIN) {
         break;
       }
-      else if(rc) {
+      else if(rc ||
+              !(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) ||
+              (attrs.filesize == 0)) {
         /*
          * libssh2_sftp_open() didn't return an error, so maybe the server
          * just doesn't support stat()
+         * OR the server doesn't return a file size with a stat()
+         * OR file size is 0
          */
         data->req.size = -1;
         data->req.maxdownload = -1;