aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-06-28 15:28:04 +0200
committerDaniel Stenberg <daniel@haxx.se>2016-06-28 15:30:17 +0200
commitb6ddc0ac075ecb7e86b25a26ba2faf7e7880ce13 (patch)
tree2320bf77d5a745e0735ba717344061e8034c68e6
parent614b5034233b95f7a3bbbbe9b0539180fabd7527 (diff)
SFTP: set a generic error when no SFTP one exists...
... 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: 暖和的和暖
-rw-r--r--lib/ssh.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index b98d60a68..e72b7561e 100644
--- 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);