[PATCH] Don't crash on empty ftp paths
- From: Christian Neumair <chris gnome-de org>
- To: gnome-vfs-list gnome org
- Subject: [PATCH] Don't crash on empty ftp paths
- Date: Sun, 19 Mar 2006 18:24:22 +0100
The attached patch is meant to fix bug 308231 [1] by replacing some
occurences of
uri->text
by
uri->text != NULL ? uri->text : "/"
It also fixes two hypothetical memleaks, which probably will never be an
issue, since I've never seen a GnomeVFS FTP URI with uri->text strlen 0,
i.e with a "" text, which is why I just checked for validity of the
URI's text to discover empty paths.
[1] http://bugzilla.gnome.org/show_bug.cgi?id=308231
Index: modules/ftp-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/ftp-method.c,v
retrieving revision 1.121
diff -u -p -r1.121 ftp-method.c
--- modules/ftp-method.c 11 Jan 2006 11:43:06 -0000 1.121
+++ modules/ftp-method.c 19 Mar 2006 17:17:55 -0000
@@ -608,6 +608,7 @@ do_path_command (FtpConnection *conn,
* than the full path. Useful for some (buggy?) systems. */
unescaped = gnome_vfs_unescape_string (uri->text, G_DIR_SEPARATOR_S);
if (unescaped == NULL || unescaped[0] == '\0') {
+ g_free (unescaped);
unescaped = g_strdup ("/");
}
@@ -774,6 +775,7 @@ do_path_transfer_command (FtpConnection
unescaped = gnome_vfs_unescape_string (uri->text, G_DIR_SEPARATOR_S);
if (unescaped == NULL || unescaped[0] == '\0') {
+ g_free (unescaped);
unescaped = g_strdup ("/");
}
@@ -1618,7 +1620,7 @@ invalidate_dirlist_cache (GnomeVFSURI *u
G_LOCK (connection_pools);
pool = ftp_connection_pool_lookup (uri);
g_hash_table_remove (pool->cached_dirlists,
- uri->text);
+ uri->text != NULL ? uri->text : "/");
G_UNLOCK (connection_pools);
}
@@ -2432,7 +2434,7 @@ do_open_directory (GnomeVFSMethod *metho
G_LOCK (connection_pools);
pool = ftp_connection_pool_lookup (uri);
cached_dirlist = g_hash_table_lookup (pool->cached_dirlists,
- uri->text);
+ uri->text != NULL ? uri->text : "/");
if (cached_dirlist != NULL) {
gettimeofday (&tv, NULL);
@@ -2513,7 +2515,7 @@ do_open_directory (GnomeVFSMethod *metho
cached_dirlist->read_time = tv.tv_sec;
g_hash_table_replace (pool->cached_dirlists,
- g_strdup (uri->text),
+ g_strdup (uri->text != NULL ? uri->text : "/"),
cached_dirlist);
G_UNLOCK (connection_pools);
@@ -2635,7 +2640,7 @@ do_read_directory (GnomeVFSMethod *metho
GNOME_VFS_FILE_INFO_SET_SYMLINK (file_info, TRUE);
file_info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME;
- file_info->symlink_name = gnome_vfs_unescape_string (uri->text, "/");
+ file_info->symlink_name = gnome_vfs_unescape_string (uri->text != NULL ? uri->text : "/", "/");
g_free (file_info->name);
file_info->name = real_name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]