Skip to content

T220: Opening sftp fails in non-blocking mode

Description

Originally reported by Karimerto: https://bugs.libssh.org/T220

If a session is set into non-blocking mode, trying to initialize a new sftp session using sftp_new will always fail. The SFTP subsystem should support async operations same as everything else.

The reason it fails is obvious (in sftp.c:150):

    if (ssh_channel_open_session(sftp->channel)) {
        goto error;
    }

    if (ssh_channel_request_sftp(sftp->channel)) {
        goto error;
    }

Both ssh_channel_open_session and ssh_channel_request_sftp can return SSH_AGAIN which is not handled at all in the above section. I think these parts of the initialization should be moved out of sftp_new and into sftp_init or some other function. Or alternatively sftp_new should be callable multiple times, same as most other functions.

Comments:

Jakuje commented on 2020-04-09 16:56:05 UTC:

Thank you for the report. You are right, this does not look like covered by any existing test case. The only one covered is the blocking mode in tests/client/torture_sftp_read.c. Contributions are always welcomed.


To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information