GabriRuflex commented on issue #275:
URL: https://github.com/apache/mina-sshd/issues/275#issuecomment-1325329363
Hi Tomas and thanks for your support!
> What does the _remote_ device run?
SSH 2.0, unfortunately no more details :(
> Three points:
>
> 1. The exception occurs after having received an error reply from the
server in response to the `sftp.open()` call. So even if this particular
exception is fixed, your problem will not be solved.
I tried also to mount the remote filesystem but it's still not working (only
in that specific device)
```
...
SftpFileSystemProvider provider = new SftpFileSystemProvider(client);
try (FileSystem fs = provider.newFileSystem(session)) {
Path remotePath = fs.getPath(remotefilepath);
try {
Files.copy(localfileStream, remotePath,
StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {}
}
...
```
```
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.checkAttributesResponse(AbstractSftpClient.java:298)
at
deployment.test.ear//org.apache.sshd.sftp.client.impl.AbstractSftpClient.checkAttributes(AbstractSftpClient.java:283)
at
deployment.test.ear//org.apache.sshd.sftp.client.impl.AbstractSftpClient.stat(AbstractSftpClient.java:997)
at
deployment.test.ear//org.apache.sshd.sftp.client.fs.SftpFileSystem$Wrapper.stat(SftpFileSystem.java:412)
at
deployment.test.ear//org.apache.sshd.sftp.client.fs.SftpFileSystemProvider.resolveRemoteFileAttributes(SftpFileSystemProvider.java:981)
at
deployment.test.ear//org.apache.sshd.sftp.client.fs.SftpFileSystemProvider.lambda$readRemoteAttributes$0(SftpFileSystemProvider.java:969)
at
deployment.test.ear//org.apache.sshd.sftp.client.impl.SftpPathImpl.withAttributeCache(SftpPathImpl.java:120)
at
deployment.test.ear//org.apache.sshd.sftp.client.impl.SftpPathImpl.withAttributeCache(SftpPathImpl.java:140)
at
deployment.test.ear//org.apache.sshd.sftp.client.fs.SftpFileSystemProvider.readRemoteAttributes(SftpFileSystemProvider.java:969)
at
deployment.test.ear//org.apache.sshd.sftp.client.impl.AbstractSftpFileAttributeView.readRemoteAttributes(AbstractSftpFileAttributeView.java:71)
at
deployment.test.ear//org.apache.sshd.sftp.client.fs.SftpPosixFileAttributeView.readAttributes(SftpPosixFileAttributeView.java:52)
at
deployment.test.ear//org.apache.sshd.sftp.client.fs.SftpPosixFileAttributeView.readAttributes(SftpPosixFileAttributeView.java:40)
at
deployment.test.ear//org.apache.sshd.sftp.client.fs.SftpFileSystemProvider.checkAccess(SftpFileSystemProvider.java:826)
at
deployment.test.ear//org.apache.sshd.sftp.client.fs.SftpFileSystemProvider.delete(SftpFileSystemProvider.java:581)
at
java.base/java.nio.file.spi.FileSystemProvider.deleteIfExists(FileSystemProvider.java:787)
at java.base/java.nio.file.Files.deleteIfExists(Files.java:1181)
at java.base/java.nio.file.Files.copy(Files.java:3055)
at
deployment.test.ear//com.test.UploadFile.upload(UploadFile.java:109)
```
> 2. The `BufferException: Underflow: requested=4, available=0` [at that
point](https://github.com/apache/mina-sshd/blob/45fd3a4a84c453a5e053cce624f63465844deb07/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/AbstractSftpClient.java#L248)
indicates that the server sent no error message or language tag in the error
status reply. I can't find any information that would say these were
optional... but Apache MINA sshd could perhaps be lenient and consider them so.
I can login to that device via CLI using `ssh` or `sftp` tools. Also other
java libraries can do that.
> 3. The failing code has been touched last 8 years ago, so the problem
is certainly not new in 2.9.2. I wonder why this problem never was reported
before? Probably the remote device runs a very old version of SFTP. [Prior to
SFTP version
3](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-09#section-12.4),
the SSH_FXP_STATUS reply indeed didn't have the error message and language tag
fields.
I'm trying to migrate from another java library (which is working properly)
to Apache MINA sshd so I don't know if this issue is new or it a regression
related to the latest version
On the old library I just added a try catch to ignore the SSH_FXP_STATUS
error and go ahead with the execution.
The current SFTP version is 3
```
sftp> version
SFTP protocol version 3
```
--
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]