GabriRuflex opened a new issue, #275:
URL: https://github.com/apache/mina-sshd/issues/275
### Version
2.9.2
### Bug description
On specific devices I got BufferException exception when I open new SFTP
session in order to upload a local file to the remote device.
This is the code I use:
```
...
byte[] localfileBytes = new FileInputStream(localfilepath).readAllBytes();
try (SftpClient sftp =
DefaultSftpClientFactory.INSTANCE.createSftpClient(session)) {
try (SftpClient.CloseableHandle handle = sftp.open(remotefilepath,
EnumSet.of(SftpClient.OpenMode.Write,
SftpClient.OpenMode.Create))) {
sftp.write(handle, 0, localfileBytes, 0, localfileBytes.length);
} catch (IOException e) {}
} catch (IOException e) {}
...
```
### Actual behavior
The file is not uploaded to the remote device. I tried with both relative
and absolute paths.
### Expected behavior
The file must be uploaded to the remote device.
### Relevant log output
```Shell
org.apache.sshd.common.util.buffer.BufferException: Underflow: requested=4,
available=0
at
deployment.test.ear//org.apache.sshd.common.util.buffer.Buffer.ensureAvailable(Buffer.java:635)
at
deployment.test.ear//org.apache.sshd.common.util.buffer.Buffer.getUInt(Buffer.java:281)
at
deployment.test.ear//org.apache.sshd.common.util.buffer.Buffer.getInt(Buffer.java:277)
at
deployment.test.ear//org.apache.sshd.common.util.buffer.ByteArrayBuffer.getString(ByteArrayBuffer.java:240)
at
deployment.test.ear//org.apache.sshd.common.util.buffer.Buffer.getString(Buffer.java:309)
at
deployment.test.ear//org.apache.sshd.sftp.client.impl.AbstractSftpClient.checkHandleResponse(AbstractSftpClient.java:248)
at
deployment.test.ear//org.apache.sshd.sftp.client.impl.AbstractSftpClient.checkHandle(AbstractSftpClient.java:232)
at
deployment.test.ear//org.apache.sshd.sftp.client.impl.AbstractSftpClient.open(AbstractSftpClient.java:573)
at
deployment.test.ear//com.test.UploadFile.upload(UploadFile.java:106)
```
### Other information
The local device run OpenSSH 8.0p1.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]