-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SFTP fails and returns BufferException during file upload #275
Comments
What does the remote device run? Three points:
|
Hi Tomas and thanks for your support!
SSH 2.0, unfortunately no more details :(
I tried also to mount the remote filesystem but it's still not working (only in that specific device)
I can login to that device via CLI using
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
|
Could you please run your client code with debug logging on and post or attach the log here? |
Put file:
LS and remove file:
If I try to remove the file using MINA sshd library, the file is removed but a BufferException is returned:
|
Sorry for not having been clear enough: I'm interested in the debug log of your Java client that is using Apache MINA SSHD and that is getting the exception. And please show the full log from the initial connection to the exception. |
This is the code:
Log:
|
Yes, that is the code. But what about the debug log when you run that code? (You should include a logging back-end in your test application, for instance slf4j-simple, and then configure it to produce logging output at the debug level.) |
|
Thanks. So this is some device using Huawei VRP. (The server identifies as SSH-2.0-HUAWEI-1.5.) Indeed the negotiated SFTP version is SFTP v3. I'll fix this |
Introduce a message record for SSH_FXP_STATUS to centralize parsing it from a buffer. Treat the error message and the language tag as optional because these fields exist only since SFTP v3, and apparently there are SFTP v3 servers that don't send it. Bug: apache#275
Log all SFTP requests and replies at debug level, and include the command name in the log message. A simple grep for SSH_FXP or SSH_FX should then find all lines relating to SFTP commands.
Actually, it's a bit worse: the very first of the SFTP v3 drafts also did not have these two fields yet. They appeared only in the second SFTPv3 draft. Therefore there may indeed be old servers that implement only that very early specification, and rightfully claim to implement SFTPv3 but not send these fields. In order to support such old SFTPv3 servers, an SFTP client must treat the error message and language tag fields in SSH_FXP_STATUS as optional. Note: this also means that if the SSH implementation used by this device is OpenSSH, it must be a truly ancient version <OpenSSH 2.5.2p2, which was released 2001-03-22! |
Introduce a message record for SSH_FXP_STATUS to centralize parsing it from a buffer. Treat the error message and the language tag as optional. These fields did not exist in the first draft of SFTP v3.[1] They only exist since the second draft[2]. There are still old SFTP server implementations that implement SFTP v3 but don't send these two fields. [1] https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-00#section-7 [2] https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-01#section-6 Bug: apache#275
Log all SFTP requests and replies at debug level, and include the command name in the log message. A simple grep for SSH_FXP or SSH_FX should then find all lines relating to SFTP commands.
@GabriRuflex : a fix for this problem has been merged. If there is still a problem with SFTP uploads to that device using the current master branch of Apache MINA SSHD, feel free to open a new bug report. (I suspect there might be, since the server should respond to an open() call with an SSH_FXP_STATUS reply only if it encountered an error. If the open() succeeds, it should send back an SSH_FXP_HANDLE response.) |
Thanks Tomas. I'll test it on monday and I'll inform you about the results 😄 |
If I use the SftpFileSystemProvider there are no issue anymore and the file upload works properly, thanks!
Log:
If I use a simple SftpClient with
Log:
|
Looks like we should also write the file open modes to the log. Using the file system
I don't know why the server seems to have a problem with the direct open() call. I don't really see how I could help here further. AFAIK, the actual open() call is in both cases the very same piece of code in Apache MINA sshd. So any difference in server behavior must be caused by different request parameters (different flags), or a different device state (such as the file already existing). |
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:
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
Other information
The local device run OpenSSH 8.0p1.
The text was updated successfully, but these errors were encountered: