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

Archive Index This month's Index

Subject: [libssh2] #249: sftp download data corruption

[libssh2] #249: sftp download data corruption

From: libssh2 Trac <trac_at_libssh2.stuge.se>
Date: Tue, 16 Oct 2012 16:48:16 -0000

#249: sftp download data corruption
 Reporter: maxmtl | Owner:
     Type: defect | Status: new
 Priority: normal | Milestone: 1.4.3
Component: SFTP | Version: 1.4.2
 Keywords: | Blocked By:
   Blocks: |
 When using libssh2's sftp to receive a file from an Apache Mina SSHD
 server (v0.6), the file is corrupted.

 Other clients (sftp from Openssh, Filezilla) does not show this behavior.
 Other SSH servers do not show this behavior.

 The problem seems to be that when libssh2 asks for 2000 bytes in
 SSH_FXP_READ, Mina SSHD always returns 32KB. When the SSH_FXP_DATA packet
 is received, all 32KB is sent to the application instead of only 2000
 bytes. However, the next 32KB received will have an offset of 2000 instead
 of 32KB, thus corrupting the file.

 The solutions:
 - libssh2: limit the length of the chunk to the length of data that was
 requested (see patch)
 - Mina: correct the length of the data sent

 With the attached patch it works, but takes much more time to complete
 (2m27 for a 2 MB file, instead of around 14 seconds). At least, the data
 is not corrupted.

Ticket URL: <https://trac.libssh2.org/ticket/249>
libssh2 <https://trac.libssh2.org/>
C library for writing portable SSH2 clients
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2012-10-16

the libssh2 team