www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: sftp problem reading large directories

Re: sftp problem reading large directories

From: E L <crc1021_at_gmail.com>
Date: Tue, 13 Mar 2012 09:52:40 -0500

> On Mon, Mar 12, 2012 at 4:57 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
>>
>> On Mon, 12 Mar 2012, Daniel Stenberg wrote:
>>
>>>> It appears to be an issue with the recent change to move the window adjustment from channel.c to the calling function. The sftp_read() function now calls _libssh2_channel_receive_window_adjust(), but there is nothing in sftp_readdir().
>>>
>>>
>>> Oops. My fault. I'll write up a fix soonish!
>>
>>
>> Thanks for a good report. I used this script:
>>
>>  #!/usr/bin/perl
>>
>>  my $l= 'A' x 100;
>>  foreach my $i (0 .. 100000) {
>>      my $name = $i.$l;
>>      open(F, ">$name") or die "stupid program: $!";
>>      print F $name;
>>      close(F);
>>  }
>>
>> ... and could easily repeat this problem locally. I then wrote a fix that properly sends updated window size to the remote. I've now pushed my fix to the git repo using hash 7194a9bd7ba45.
>>
>> I'll appreciate if you test it and give us your comments!
>>

I spoke a little too soon. The reading of large directories is
working, but now the read of large files is not working for one server
(GlobalScape). Something appears to get corrupted because after
receiving about 650k out of 15M, one packet length comes back
completely bogus.

[libssh2] 14.210771 Transport: Packet type 94 received, length=118
[libssh2] 14.210771 Conn: 109 bytes packet_add() for 0/0/0
[libssh2] 14.210771 Conn: channel_read() got 2009 of data from 0/0/0
[libssh2] 14.210771 SFTP: Received packet 60 (len 2009)
[libssh2] 14.210771 SFTP: recv packet
[libssh2] 14.210771 Conn: channel_read() got 4 of data from 0/0/0
[libssh2] 14.210771 SFTP: Data begin - Packet Length: 1668048225
[libssh2] 14.210771 Failure Event: -25 - SFTP packet too large
(I moved the debug line for Packet Length so I could see the value
before the error)

I'm not sure if this is the cause of what I'm seeing, but if the code
in sftp_packet_read() jumps to window_adjust, the packet buffer will
not be initialized but the execution can still continue to where
packet is used.

Eric

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2012-03-13

the libssh2 team