cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

Re: SFTP fails (Failure when receiving data from the peer)

From: Markus Moeller <huaraz_at_moeller.plus.com>
Date: Sun, 14 Dec 2008 14:00:10 -0000

Daniel,

I did run curl now with libssh2 debug and it seems to be another error than
the mentioned one in libssh2-devel.

[libssh2] Failure Event: -25 - Packet contains more data than we offered to
receive, truncating

The client is requesting in maximal 16384 bytes with SSH_FXP_READ, but
receives 16397 bytes, which shouldn't happen. So I guess it is a server bug
or is there any requirement of the length given in SSH_FXP_READ being
smaller by a set amount (e.g. 13 bytes for some headers ?) than
LIBSSH2_CHANNEL_PACKET_DEFAULT ?
If I change the max length in the SSH_FXP_READ to

if (bytes_requested > buffer_maxlen -13) {
    bytes_requested = buffer_maxlen -13;
}

I get the file. (13 is based on seen read bytes (16397) - request bytes
(16384) = 13 and comments about 13 bytes of header length)

Markus

BTW: The server identifies itself with
debug1: Remote protocol version 2.0, remote software version 1.36_sshlib
afts.

[libssh2] SFTP Subsystem: Asking for 105 packet
[libssh2] SFTP Subsystem: Reading 16384 bytes from SFTP handle
[libssh2] SFTP Subsystem: Requesting 16384 bytes from SFTP handle
[libssh2] Connection: Writing 26 bytes on channel 0/0, stream #0
[libssh2] Connection: Sending 26 bytes on channel 0/0, stream_id=0
[libssh2] SFTP Subsystem: _requirev(): Initialize timeout
[libssh2] SFTP Subsystem: Waiting for packet
[libssh2] Connection: Attempting to read 4 bytes from channel 0/0 stream #0
[libssh2] SFTP Subsystem: Asking for 103 packet
[libssh2] SFTP Subsystem: Asking for 101 packet
[libssh2] SFTP Subsystem: Waiting for packet
  % Total % Received % Xferd Average Speed Time Time Time
Current
                                 Dload Upload Total Spent Left
Speed

  0 370k 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:--
0
[libssh2] SFTP Subsystem: Requesting 16384 bytes from SFTP handle
[libssh2] SFTP Subsystem: Asking for 103 packet
[libssh2] SFTP Subsystem: Asking for 101 packet
[libssh2] SFTP Subsystem: Waiting for packet
[libssh2] Transport: Packet type 94 received, length=16406
[libssh2] Connection: 16397 bytes received for channel 0/0 stream #0
[libssh2] Failure Event: -25 - Packet contains more data than we offered to
receive, truncating
[libssh2] Connection: Reading 4 of buffered data from 0/0/0
[libssh2] SFTP Subsystem: Data begin - Packet Length: 16393
[libssh2] Connection: Attempting to read 16393 bytes from channel 0/0 stream
#0
[libssh2] Connection: Reading 16380 of buffered data from 0/0/0
[libssh2] Connection: Unlinking empty packet buffer from channel 0/0
[libssh2] Connection: Adjusting window 16467 bytes for data flushed from
channel 0/0
[libssh2] Connection: Attempting to read 13 bytes from channel 0/0 stream #0
[libssh2] SFTP Subsystem: Requesting 16384 bytes from SFTP handle
[libssh2] SFTP Subsystem: Asking for 103 packet
[libssh2] SFTP Subsystem: Asking for 101 packet
[libssh2] SFTP Subsystem: Waiting for packet

  0 370k 0 0 0 0 0 0 --:--:-- 0:00:04 --:--:--
0
[libssh2] SFTP Subsystem: Requesting 16384 bytes from SFTP handle
[libssh2] SFTP Subsystem: Asking for 103 packet
[libssh2] SFTP Subsystem: Asking for 101 packet
[libssh2] SFTP Subsystem: Waiting for packet

  0 370k 0 0 0 0 0 0 --:--:-- 0:00:05 --:--:--
0
[libssh2] SFTP Subsystem: Requesting 16384 bytes from SFTP handle
[libssh2] SFTP Subsystem: Asking for 103 packet
[libssh2] SFTP Subsystem: Asking for 101 packet
[libssh2] SFTP Subsystem: Waiting for packet

Markus

"Markus Moeller" <huaraz_at_moeller.plus.com> wrote in message
news:gi0o8c$bcd$1_at_ger.gmane.org...
>I think I found the issue in libssh2 (see my post in libssh2-devel)
>
> Markus
>
> "Daniel Stenberg" <daniel_at_haxx.se> wrote in message
> news:alpine.LRH.2.00.0812102233530.8669_at_yvahk3.pbagnpgbe.fr...
>> On Wed, 10 Dec 2008, Markus Moeller wrote:
>>
>>> I am using curl 7.19.2 with libssh2 2.0.18 and see the same issue as
>>> described below (e.g recv returns -1) and I can't download a file with
>>> sftp. So, basically it isn't usable as it works sometimes and sometimes
>>> it doesn't.
>>>
>>> What is the solution to this problem ? Do I need a snapshot libssh2 and
>>> a curl fix ?
>>
>> The problem described, which seems to be happening when libssh2 gets a
>> buffer size of 16K passed to it when reading data from an SFTP
>> connection, is a problem with libssh2 - I don't see how a libcurl change
>> can be the right fix.
>>
>> The correct approach here is to work on the libssh2 library to fix this
>> flaw. This thread on the libssh2-devel list seems to be "the one":
>>
>> https://sourceforge.net/mailarchive/forum.php?thread_name=9c3275a90811261517v6c0b1da2u918cc1b8370abf83%40mail.gmail.com&forum_name=libssh2-devel
>>
>> I've not yet managed to find enough time and energy and motivation to
>> work on that problem myself.
>>
>> --
>>
>> / daniel.haxx.se
>>
>
>
>
Received on 2008-12-14

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET