MINA SSHD
  1. MINA SSHD
  2. SSHD-105

sftp: com.jcraft.jsch client can't get files

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.5.0
    • Fix Version/s: 0.6.0
    • Labels:
      None
    • Environment:
      windows xp

      Description

      com.jcraft.jsch.ChannelSftp.get(String src, String dst, SftpProgressMonitor monitor, int mode) throws exception when trying to get a file from Apache sshd.
      No problem with jcraft<-->OpenSSH.
      No problem with sftp command line tool<-->Apache sshd either.

      4:
              at com.jcraft.jsch.ChannelSftp._get(ChannelSftp.java:980)
              at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:832)
              at org.apache.sshd.TestJcraftSftp.getfile(TestJcraftSftp.java:127)
              at org.apache.sshd.TestJcraftSftp.testJcraftSftp(TestJcraftSftp.java:138)
      ...
      Caused by: java.lang.IndexOutOfBoundsException
              at java.io.PipedInputStream.read(PipedInputStream.java:355)
              at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2325)
              at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2317)
              at com.jcraft.jsch.ChannelSftp.checkStatus(ChannelSftp.java:1930)
              at com.jcraft.jsch.ChannelSftp._sendCLOSE(ChannelSftp.java:1943)
              at com.jcraft.jsch.ChannelSftp._get(ChannelSftp.java:975)
              ... 26 more
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.656 sec <<< FAILURE!
      

      com.jcraft.jsch sftp client is used in Talend Open Studio http://www.talendforge.org/

      Test case attached/

        Activity

        Hide
        Guillaume Nodet added a comment -

        Thx a ton guys!

        Committing to https://svn.apache.org/repos/asf/mina/sshd/trunk ...
        M sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystem.java
        Committed r1090126

        Show
        Guillaume Nodet added a comment - Thx a ton guys! Committing to https://svn.apache.org/repos/asf/mina/sshd/trunk ... M sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystem.java Committed r1090126
        Hide
        Bobby Powers added a comment -

        added a patch, this looks right.

        version 6 of the spec adds
        bool end-of-file [optional]
        to the SSH_FXP_DATA reply. This isn't in version 4 of the spec. See
        page 28 of the v4 spec and page 52 of the v6 spec:
        v4: http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04
        v6: http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13

        Show
        Bobby Powers added a comment - added a patch, this looks right. version 6 of the spec adds bool end-of-file [optional] to the SSH_FXP_DATA reply. This isn't in version 4 of the spec. See page 28 of the v4 spec and page 52 of the v6 spec: v4: http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04 v6: http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13
        Hide
        E. Schreiner added a comment -

        a version check

        if (version >= 6)

        { buf.putBoolean(len == 0); //introduced in SFTP 6 }

        worked for me in a similar problem with jsch: i didn't had this exception but the received files contained additional bytes.

        looks like jsch implements SFTP 5 or less...

        Show
        E. Schreiner added a comment - a version check if (version >= 6) { buf.putBoolean(len == 0); //introduced in SFTP 6 } worked for me in a similar problem with jsch: i didn't had this exception but the received files contained additional bytes. looks like jsch implements SFTP 5 or less...
        Hide
        Ilya Basin added a comment -

        As a workaround for this client I commented: buf.putBoolean(len == 0); in SftpSubsystem.java

        Show
        Ilya Basin added a comment - As a workaround for this client I commented: buf.putBoolean(len == 0); in SftpSubsystem.java
        Hide
        Ilya Basin added a comment -

        test case

        Show
        Ilya Basin added a comment - test case

          People

          • Assignee:
            Unassigned
            Reporter:
            Ilya Basin
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development