hierynomus / sshj

ssh, scp and sftp for java
Apache License 2.0
2.51k stars 601 forks source link

ArrayIndexOutOfBounds Exception #528

Open NikolayMetchev opened 5 years ago

NikolayMetchev commented 5 years ago

I am trying to upload a file to an sftp server and I suspect they are using old ciphers on their end which is resulting in the following exception: Any help will be appreciated:

[2019-08-23 17:46:45:073] [INFO] [pool-4-thread-1] [] [BouncyCastleRandom:48] - Generating random seed from SecureRandom.
[2019-08-23 17:46:45:229] [INFO] [pool-4-thread-1] [] [TransportImpl:214] - Client identity string: SSH-2.0-SSHJ_0.27.0
[2019-08-23 17:46:45:319] [INFO] [pool-4-thread-1] [] [TransportImpl:178] - Server identity string: SSH-2.0-.
[2019-08-23 17:46:45:931] [INFO] [pool-4-thread-1] [] [SessionChannel:187] - Will request `sftp` subsystem
[2019-08-23 17:46:48:918] [INFO] [reader] [] [TransportImpl:547] - Received SSH_MSG_DISCONNECT (reason=BY_APPLICATION, msg=User Disconnected)
[2019-08-23 17:46:48:934] [ERROR] [reader] [] [TransportImpl:593] - Dying because - User Disconnected
net.schmizz.sshj.transport.TransportException: User Disconnected
    at net.schmizz.sshj.transport.TransportImpl.gotDisconnect(TransportImpl.java:548) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:508) [sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.transport.Decoder.decodeMte(Decoder.java:159) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:79) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.transport.Decoder.received(Decoder.java:231) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.transport.Reader.run(Reader.java:59) [sshj-0.27.0.jar:0.27.0]
[2019-08-23 17:46:48:934] [INFO] [reader] [] [TransportImpl:192] - Disconnected - BY_APPLICATION
[2019-08-23 17:46:48:996] [INFO] [pool-4-thread-1] [] [TransportImpl:192] - Disconnected - BY_APPLICATION
[2019-08-23 17:46:49:012] [ERROR] [pool-4-thread-1] [] [SftpConnection:101] - Failed to upload  Attempt 1
net.schmizz.sshj.transport.TransportException: Software caused connection abort: socket write error
    at net.schmizz.sshj.transport.TransportImpl.write(TransportImpl.java:454) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.connection.channel.ChannelOutputStream$DataBuffer.flush(ChannelOutputStream.java:102) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.connection.channel.ChannelOutputStream$DataBuffer.write(ChannelOutputStream.java:60) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.connection.channel.ChannelOutputStream.write(ChannelOutputStream.java:141) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.sftp.SFTPEngine.transmit(SFTPEngine.java:296) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.sftp.SFTPEngine.request(SFTPEngine.java:130) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.sftp.RemoteFile.asyncWrite(RemoteFile.java:83) ~[sshj-0.27.0.jar:0.27.0]
    at net.schmizz.sshj.sftp.RemoteFile.write(RemoteFile.java:78) ~[sshj-0.27.0.jar:0.27.0]
    at com.bluecove.sftp.SftpConnection.lambda$uploadFile$0(SftpConnection.java:97) ~[classes/:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) [?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
    at java.lang.Thread.run(Thread.java:834) [?:?]
    Suppressed: java.lang.ArrayIndexOutOfBoundsException: Index -5 out of bounds for length 65536
        at net.schmizz.sshj.common.Buffer.putUInt32(Buffer.java:320) ~[sshj-0.27.0.jar:0.27.0]
        at net.schmizz.sshj.transport.Encoder.encode(Encoder.java:102) ~[sshj-0.27.0.jar:0.27.0]
        at net.schmizz.sshj.transport.TransportImpl.write(TransportImpl.java:449) ~[sshj-0.27.0.jar:0.27.0]
        at net.schmizz.sshj.connection.channel.ChannelOutputStream$DataBuffer.flush(ChannelOutputStream.java:102) ~[sshj-0.27.0.jar:0.27.0]
        at net.schmizz.sshj.connection.channel.ChannelOutputStream$DataBuffer.write(ChannelOutputStream.java:60) ~[sshj-0.27.0.jar:0.27.0]
        at net.schmizz.sshj.connection.channel.ChannelOutputStream.write(ChannelOutputStream.java:141) ~[sshj-0.27.0.jar:0.27.0]
        at net.schmizz.sshj.connection.channel.ChannelOutputStream.write(ChannelOutputStream.java:131) ~[sshj-0.27.0.jar:0.27.0]
        at net.schmizz.sshj.sftp.SFTPEngine.transmit(SFTPEngine.java:292) ~[sshj-0.27.0.jar:0.27.0]
        at net.schmizz.sshj.sftp.SFTPEngine.request(SFTPEngine.java:130) ~[sshj-0.27.0.jar:0.27.0]
        at net.schmizz.sshj.sftp.RemoteResource.close(RemoteResource.java:53) ~[sshj-0.27.0.jar:0.27.0]
        at com.bluecove.sftp.SftpConnection.lambda$uploadFile$0(SftpConnection.java:93) ~[classes/:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method) ~[?:?]
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:110) ~[?:?]
    at java.net.SocketOutputStream.write(SocketOutputStream.java:150) ~[?:?]
    at net.schmizz.sshj.transport.TransportImpl.write(TransportImpl.java:451) ~[sshj-0.27.0.jar:0.27.0]
    ... 14 more
simon04 commented 4 years ago

Duplicate of https://github.com/hierynomus/sshj/issues/461?