@@ -1096,18 +1096,22 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE *
handle, char *buffer,
         memcpy(buffer, &filep->data[ filep->data_len - filep->data_left],
                copy);

         total_read += copy;
         filep->data_left -= copy;
+        filep->offset += copy;

         if(filep->data_left)
             return total_read;

         LIBSSH2_FREE(session, filep->data);
         filep->data = NULL;
     }

+    if (total_read == buffer_size)
+        return total_read;
+
     /* We allow a number of bytes being requested at any given time without
        having been acked - until we reach EOF. */
     if(!filep->eof) {
         /* if the buffer_size passed in now is smaller than what has
already
            been sent, we risk getting count become a very large number */
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to