You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Michael Binder (JIRA)" <ji...@apache.org> on 2017/08/23 14:38:00 UTC

[jira] [Created] (SSHD-765) SFTP client fails to retrieve a binary file using an InputStream

Michael Binder created SSHD-765:
-----------------------------------

             Summary: SFTP client fails to retrieve a binary file using an InputStream
                 Key: SSHD-765
                 URL: https://issues.apache.org/jira/browse/SSHD-765
             Project: MINA SSHD
          Issue Type: Bug
    Affects Versions: 1.6.0
            Reporter: Michael Binder


The SFTP client fails to retrieve a binary file from an SFTP server using the InputStream returned by the {{SftpClient.read (String)}} method.

In my case the binary file was actually a gzipped XML file. So I wrapped the returned InputStream in a {{java.util.zip.GZIPInputStream}} object. When reading from the stream I received an IOException with following message:
"org.apache.sshd.client.subsystem.sftp.SftpInputStreamWithChannel.read() returned value out of range -1..255: -117".

I think that this method violates the contract given in {{java.io.InputStream}}: "The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned."

After I patched line 131 in SftpInputStreamWithChannel.java to
{code:java}
            return bb[0] & 0xFF;
{code}
retrieving the file seemed to have worked fine.




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)