]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
SFTP: set a generic error when no SFTP one exists...
authorDaniel Stenberg <daniel@haxx.se>
Tue, 28 Jun 2016 13:28:04 +0000 (15:28 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 28 Jun 2016 13:30:17 +0000 (15:30 +0200)
... as otherwise we could get a 0 which would count as no error and we'd
wrongly continue and could end up segfaulting.

Bug: https://curl.haxx.se/mail/lib-2016-06/0052.html
Reported-by: 暖和的和暖
lib/ssh.c

index b98d60a68250b2a237bd589f714bea135cd10991..e72b7561e0779f5d03e5b1cd8f04c14167d8764b 100644 (file)
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -1161,8 +1161,13 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
       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
+          /* in this case, the error wasn't in the SFTP level but for example
+             a time-out or similar */
+          result = CURLE_SSH;
+        sshc->actualcode = result;
         DEBUGF(infof(data, "error = %d makes libcurl = %d\n",
                      err, (int)result));
         state(conn, SSH_STOP);