Merge branch '3456_sftp_segfault'

* 3456_sftp_segfault:
  Ticket #3456: SFTP VFS: fix segfault.
This commit is contained in:
Andrew Borodin 2015-05-24 17:34:03 +03:00
commit 4167717e4c
8 changed files with 32 additions and 28 deletions

View File

@ -435,12 +435,16 @@ message (int flags, const char *title, const char *text, ...)
/** Show error message box */
gboolean
mc_error_message (GError ** mcerror)
mc_error_message (GError ** mcerror, int *code)
{
if (mcerror == NULL || *mcerror == NULL)
return FALSE;
message (D_ERROR, MSG_ERROR, _("%d: %s"), (*mcerror)->code, (*mcerror)->message);
if (code != NULL)
*code = (*mcerror)->code;
g_error_free (*mcerror);
*mcerror = NULL;

View File

@ -84,7 +84,7 @@ struct WDialog *create_message (int flags, const char *title,
void message (int flags, const char *title, const char *text, ...)
__attribute__ ((format (__printf__, 3, 4)));
gboolean mc_error_message (GError ** mcerror);
gboolean mc_error_message (GError ** mcerror, int *code);
status_msg_t *status_msg_create (const char *title, double delay, status_msg_cb init_cb,
status_msg_update_cb update_cb, status_msg_cb deinit_cb);

View File

@ -166,7 +166,7 @@ skin_apply (const gchar * skin_override)
panel_init ();
repaint_screen ();
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -965,7 +965,7 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char *
p += 2;
found = regex_check_type (filename_vpath, p, case_insense, &have_type, &mcerror);
if (mc_error_message (&mcerror))
if (mc_error_message (&mcerror, NULL))
error_flag = TRUE; /* leave it if file cannot be opened */
}
else if (strncmp (p, "default/", 8) == 0)

View File

@ -1472,7 +1472,7 @@ load_hotlist (void)
if (!mc_config_save_file (mc_main_config, &mcerror))
setup_save_config_show_error (mc_main_config->ini_path, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
}
stat (hotlist_file_name, &stat_buf);

View File

@ -378,7 +378,7 @@ main (int argc, char *argv[])
if (mc_global.mc_run_mode == MC_RUN_FULL)
command_set_default_colors ();
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
#ifdef ENABLE_SUBSHELL
/* Done here to ensure that the subshell doesn't */

View File

@ -155,7 +155,7 @@ sftpfs_cb_open (const vfs_path_t * vpath, int flags, mode_t mode)
if (!sftpfs_open_file (file_handler, flags, mode, &mcerror))
{
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
g_free (file_handler);
return NULL;
}
@ -184,7 +184,7 @@ sftpfs_cb_opendir (const vfs_path_t * vpath)
tty_got_interrupt ();
ret_value = sftpfs_opendir (vpath, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return ret_value;
}
@ -209,7 +209,7 @@ sftpfs_cb_readdir (void *data)
}
sftpfs_dirent = sftpfs_readdir (data, &mcerror);
if (!mc_error_message (&mcerror))
if (!mc_error_message (&mcerror, NULL))
{
if (sftpfs_dirent != NULL)
vfs_print_message (_("sftp: (Ctrl-G break) Listing... %s"), sftpfs_dirent->dent.d_name);
@ -235,7 +235,7 @@ sftpfs_cb_closedir (void *data)
GError *mcerror = NULL;
rc = sftpfs_closedir (data, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -255,7 +255,7 @@ sftpfs_cb_lstat (const vfs_path_t * vpath, struct stat *buf)
GError *mcerror = NULL;
rc = sftpfs_lstat (vpath, buf, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -275,7 +275,7 @@ sftpfs_cb_stat (const vfs_path_t * vpath, struct stat *buf)
GError *mcerror = NULL;
rc = sftpfs_stat (vpath, buf, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -295,7 +295,7 @@ sftpfs_cb_fstat (void *data, struct stat *buf)
GError *mcerror = NULL;
rc = sftpfs_fstat (data, buf, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -316,7 +316,7 @@ sftpfs_cb_readlink (const vfs_path_t * vpath, char *buf, size_t size)
GError *mcerror = NULL;
rc = sftpfs_readlink (vpath, buf, size, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -354,7 +354,7 @@ sftpfs_cb_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
GError *mcerror = NULL;
rc = sftpfs_symlink (vpath1, vpath2, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -440,7 +440,7 @@ sftpfs_cb_read (void *data, char *buffer, size_t count)
}
rc = sftpfs_read_file (fh, buffer, count, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -462,7 +462,7 @@ sftpfs_cb_write (void *data, const char *buf, size_t nbyte)
vfs_file_handler_t *fh = (vfs_file_handler_t *) data;
rc = sftpfs_write_file (fh, buf, nbyte, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -489,7 +489,7 @@ sftpfs_cb_close (void *data)
vfs_stamp_create (&sftpfs_class, super);
rc = sftpfs_close_file (file_handler, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
if (file_handler->handle != -1)
close (file_handler->handle);
@ -516,7 +516,7 @@ sftpfs_cb_chmod (const vfs_path_t * vpath, mode_t mode)
GError *mcerror = NULL;
rc = sftpfs_chmod (vpath, mode, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -536,7 +536,7 @@ sftpfs_cb_mkdir (const vfs_path_t * vpath, mode_t mode)
GError *mcerror = NULL;
rc = sftpfs_mkdir (vpath, mode, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -555,7 +555,7 @@ sftpfs_cb_rmdir (const vfs_path_t * vpath)
GError *mcerror = NULL;
rc = sftpfs_rmdir (vpath, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -577,7 +577,7 @@ sftpfs_cb_lseek (void *data, off_t offset, int whence)
GError *mcerror = NULL;
ret_offset = sftpfs_lseek (file_handler, offset, whence, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return ret_offset;
}
@ -596,7 +596,7 @@ sftpfs_cb_unlink (const vfs_path_t * vpath)
GError *mcerror = NULL;
rc = sftpfs_unlink (vpath, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}
@ -616,7 +616,7 @@ sftpfs_cb_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
GError *mcerror = NULL;
rc = sftpfs_rename (vpath1, vpath2, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return rc;
}

View File

@ -109,9 +109,9 @@ sftpfs_cb_open_connection (struct vfs_s_super *super,
super->path_element = vfs_path_element_clone (vpath_element);
sftpfs_fill_connection_data_from_config (super, &mcerror);
if (mc_error_message (&mcerror))
if (mc_error_message (&mcerror, &ret_value))
{
vpath_element->class->verrno = mcerror->code;
vpath_element->class->verrno = ret_value;
return -1;
}
@ -121,7 +121,7 @@ sftpfs_cb_open_connection (struct vfs_s_super *super,
vfs_s_default_stat (vpath_element->class, S_IFDIR | 0755));
ret_value = sftpfs_open_connection (super, &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
return ret_value;
}
@ -140,7 +140,7 @@ sftpfs_cb_close_connection (struct vfs_class *me, struct vfs_s_super *super)
(void) me;
sftpfs_close_connection (super, "Normal Shutdown", &mcerror);
mc_error_message (&mcerror);
mc_error_message (&mcerror, NULL);
g_free (super->data);
}