libssh: if sftp_init fails, don't get the sftp error code

This flow extracted the wrong code (sftp code instead of ssh code), and
the code is sometimes (erroneously) returned as zero anyway, so skip
getting it and set a generic error.

Reported-by: David McLaughlin
Fixes #9737
Closes #9740
This commit is contained in:
Daniel Stenberg 2022-10-16 12:58:55 +02:00
parent 9660f23010
commit bdaa6dd5ba
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -963,10 +963,9 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
rc = sftp_init(sshc->sftp_session);
if(rc != SSH_OK) {
rc = sftp_get_error(sshc->sftp_session);
failf(data, "Failure initializing sftp session: %s",
ssh_get_error(sshc->ssh_session));
MOVE_TO_ERROR_STATE(sftp_error_to_CURLE(rc));
MOVE_TO_ERROR_STATE(sftp_error_to_CURLE(SSH_FX_FAILURE));
break;
}
state(data, SSH_SFTP_REALPATH);