mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
Ticket #3036: fix crash after entering a wrong SFTP password.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
5fdd1027f5
commit
2b3be1dfc6
@ -376,7 +376,7 @@ sftpfs_open_connection (struct vfs_s_super *super, GError ** error)
|
|||||||
*/
|
*/
|
||||||
super_data->socket_handle = sftpfs_open_socket (super, error);
|
super_data->socket_handle = sftpfs_open_socket (super, error);
|
||||||
if (super_data->socket_handle == -1)
|
if (super_data->socket_handle == -1)
|
||||||
goto deinit_by_error;
|
return (-1);
|
||||||
|
|
||||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||||
* and setup crypto, compression, and MAC layers
|
* and setup crypto, compression, and MAC layers
|
||||||
@ -385,7 +385,7 @@ sftpfs_open_connection (struct vfs_s_super *super, GError ** error)
|
|||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
{
|
{
|
||||||
g_set_error (error, MC_ERROR, -1, _("sftp: Failure establishing SSH session: (%d)"), rc);
|
g_set_error (error, MC_ERROR, -1, _("sftp: Failure establishing SSH session: (%d)"), rc);
|
||||||
goto deinit_by_error;
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* At this point we havn't yet authenticated. The first thing to do
|
/* At this point we havn't yet authenticated. The first thing to do
|
||||||
@ -400,21 +400,17 @@ sftpfs_open_connection (struct vfs_s_super *super, GError ** error)
|
|||||||
if (!sftpfs_open_connection_ssh_agent (super, error)
|
if (!sftpfs_open_connection_ssh_agent (super, error)
|
||||||
&& !sftpfs_open_connection_ssh_key (super, error)
|
&& !sftpfs_open_connection_ssh_key (super, error)
|
||||||
&& !sftpfs_open_connection_ssh_password (super, error))
|
&& !sftpfs_open_connection_ssh_password (super, error))
|
||||||
goto deinit_by_error;
|
return (-1);
|
||||||
|
|
||||||
super_data->sftp_session = libssh2_sftp_init (super_data->session);
|
super_data->sftp_session = libssh2_sftp_init (super_data->session);
|
||||||
|
|
||||||
if (super_data->sftp_session == NULL)
|
if (super_data->sftp_session == NULL)
|
||||||
goto deinit_by_error;
|
return (-1);
|
||||||
|
|
||||||
/* Since we have not set non-blocking, tell libssh2 we are blocking */
|
/* Since we have not set non-blocking, tell libssh2 we are blocking */
|
||||||
libssh2_session_set_blocking (super_data->session, 1);
|
libssh2_session_set_blocking (super_data->session, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
deinit_by_error:
|
|
||||||
sftpfs_close_connection (super, "Shutdown with errors", NULL);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -438,6 +434,8 @@ sftpfs_close_connection (struct vfs_s_super *super, const char *shutdown_message
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
vfs_path_element_free (super_data->original_connection_info);
|
vfs_path_element_free (super_data->original_connection_info);
|
||||||
|
super_data->original_connection_info = NULL;
|
||||||
|
|
||||||
if (super_data->agent != NULL)
|
if (super_data->agent != NULL)
|
||||||
{
|
{
|
||||||
libssh2_agent_disconnect (super_data->agent);
|
libssh2_agent_disconnect (super_data->agent);
|
||||||
@ -456,8 +454,8 @@ sftpfs_close_connection (struct vfs_s_super *super, const char *shutdown_message
|
|||||||
libssh2_session_disconnect (super_data->session, shutdown_message);
|
libssh2_session_disconnect (super_data->session, shutdown_message);
|
||||||
super_data->session = NULL;
|
super_data->session = NULL;
|
||||||
}
|
}
|
||||||
if (super_data->fingerprint != NULL)
|
|
||||||
super_data->fingerprint = NULL;
|
super_data->fingerprint = NULL;
|
||||||
|
|
||||||
if (super_data->socket_handle != -1)
|
if (super_data->socket_handle != -1)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user