morpheuswang / ganymed-ssh-2

Automatically exported from code.google.com/p/ganymed-ssh-2
Other
0 stars 0 forks source link

SFTPv3Client.write fails to channel closed on version 261 #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
The following code will reproduce this error everytime:
    public static void main(String[] args) throws IOException {
        String hostname = "some-host";
        String username = "username";
        String password = "password";

        Connection c = null;
        SFTPv3Client client = null;
        try {
        c = new Connection(hostname);
        c.connect();
        c.authenticateWithPassword(username, password);
        client = new SFTPv3Client(c);
        SFTPv3FileHandle handle = client.createFile("test_basic.txt");
        byte[] arr = new byte[262120];
        client.write(handle, 0, arr, 0, arr.length);
        }
        finally {
            c.close();
            client.close();
        }
    }
This will fail for byte array size >= 262120 every time. It works for size <= 
262119.

What is the expected output? What do you see instead?
I expect no output, and the file test_basic.txt with file size 262120 bytes to 
appear in username's host directory on host somehost. Instead, I see the output:
Exception in thread "main" ch.ethz.ssh2.channel.ChannelClosedException: SSH 
channel is closed. (Close requested by remote)
    at ch.ethz.ssh2.channel.ChannelManager.sendData(ChannelManager.java:426)
    at ch.ethz.ssh2.channel.ChannelOutputStream.write(ChannelOutputStream.java:71)
    at java.io.BufferedOutputStream.write(BufferedOutputStream.java:105)
    at ch.ethz.ssh2.SFTPv3Client.sendMessage(SFTPv3Client.java:225)
    at ch.ethz.ssh2.SFTPv3Client.sendMessage(SFTPv3Client.java:231)
    at ch.ethz.ssh2.SFTPv3Client.write(SFTPv3Client.java:1507)
    at ch.ethz.ssh2.SFTPv3Client.main(SFTPv3Client.java:1637)

And the file test_basic.txt with file size 0 bytes.

What version of the product are you using? On what operating system?
Version 261. I reproduced this on Ubuntu 13.04 and Windows 7.
It succeeds on version 251beta1 (for size 262120 and much larger too).

Please provide any additional information below.
262120 is remarkably close to 1024 * 256 = 262144...

Original issue reported on code.google.com by Dan.Walk...@gmail.com on 16 Oct 2013 at 6:47

GoogleCodeExporter commented 9 years ago
For the hosts that I was connecting to, this appeared on everything I tried - 
CentOS 6.4 and Ubuntu 13.04

Original comment by Dan.Walk...@gmail.com on 16 Oct 2013 at 7:12

GoogleCodeExporter commented 9 years ago
In r97.

Original comment by dkocher@sudo.ch on 9 Apr 2014 at 8:35