From 2b3be1dfc6ff872dd32fb8eaf99fe778d2dce997 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Mon, 15 Jul 2013 15:27:19 +0400 Subject: [PATCH] Ticket #3036: fix crash after entering a wrong SFTP password. Signed-off-by: Andrew Borodin --- src/vfs/sftpfs/connection.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/vfs/sftpfs/connection.c b/src/vfs/sftpfs/connection.c index 83e33d005..d43398c49 100644 --- a/src/vfs/sftpfs/connection.c +++ b/src/vfs/sftpfs/connection.c @@ -376,7 +376,7 @@ sftpfs_open_connection (struct vfs_s_super *super, GError ** error) */ super_data->socket_handle = sftpfs_open_socket (super, error); if (super_data->socket_handle == -1) - goto deinit_by_error; + return (-1); /* ... start it up. This will trade welcome banners, exchange keys, * and setup crypto, compression, and MAC layers @@ -385,7 +385,7 @@ sftpfs_open_connection (struct vfs_s_super *super, GError ** error) if (rc != 0) { 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 @@ -400,21 +400,17 @@ sftpfs_open_connection (struct vfs_s_super *super, GError ** error) if (!sftpfs_open_connection_ssh_agent (super, error) && !sftpfs_open_connection_ssh_key (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); if (super_data->sftp_session == NULL) - goto deinit_by_error; + return (-1); /* Since we have not set non-blocking, tell libssh2 we are blocking */ libssh2_session_set_blocking (super_data->session, 1); 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; vfs_path_element_free (super_data->original_connection_info); + super_data->original_connection_info = NULL; + if (super_data->agent != NULL) { 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); super_data->session = NULL; } - if (super_data->fingerprint != NULL) - super_data->fingerprint = NULL; + + super_data->fingerprint = NULL; if (super_data->socket_handle != -1) {