cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl crahes when an SFTP server's home directory is non-exist

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 17 Jun 2016 18:52:59 +0200 (CEST)

On Fri, 17 Jun 2016, $BCHOBE*OBCH(J _ wrote:

> Maybe here need to revise the "result" since the "err" cannot be fully
> trusted, something equals to

> if(result == CURLE_OK)
> result = CURLE_SSH;

How about this patch?

--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -1159,12 +1159,15 @@ static CURLcode ssh_statemach_act(struct connectdata
*conn, bool *block)
          conn->data->state.most_recent_ftp_entrypath = sshc->homedir;
        }
        else {
          /* Return the error type */
          err = sftp_libssh2_last_error(sshc->sftp_session);
- result = sftp_libssh2_error_to_CURLE(err);
- sshc->actualcode = result?result:CURLE_SSH;
+ if(err)
+ result = sftp_libssh2_error_to_CURLE(err);
+ else
+ result = CURLE_SSH;
+ sshc->actualcode = result;
          DEBUGF(infof(data, "error = %d makes libcurl = %d\n",
                       err, (int)result));
          state(conn, SSH_STOP);
          break;
        }

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-06-17