gvfs r2222 - in trunk: . client



Author: gicmo
Date: Mon Feb 16 11:12:55 2009
New Revision: 2222
URL: http://svn.gnome.org/viewvc/gvfs?rev=2222&view=rev

Log:
2009-02-16  Christian Kellner  <gicmo gnome org>

	Bug 546256 â Crash in g_vfs_get_file_for_uri()

	* client/httpuri.c: Make sure we never return a non-NULL 
	GVfsUriMountInfo with the path component set to NULL, since
	this leads to dead kittens.
	NB: This only fixes the symptom. The real problem is deep in
	the uri parsing logic.



Modified:
   trunk/ChangeLog
   trunk/client/httpuri.c

Modified: trunk/client/httpuri.c
==============================================================================
--- trunk/client/httpuri.c	(original)
+++ trunk/client/httpuri.c	Mon Feb 16 11:12:55 2009
@@ -79,44 +79,30 @@
                const char     *uri_str)
 {
   GVfsUriMountInfo *info;
-  char *path;
   gboolean ssl;
+  GDecodedUri *uri;
 
-  path = NULL;
-  if (!g_ascii_strncasecmp (uri_str, "http", 4))
-    {
-      GDecodedUri *uri;
+  uri = g_vfs_decode_uri (uri_str);
 
-      uri = g_vfs_decode_uri (uri_str);
+  if (uri == NULL)
+    return NULL;
 
+  if (!g_ascii_strncasecmp (uri->scheme, "http", 4))
+    {
       info = g_vfs_uri_mount_info_new ("http");
       g_vfs_uri_mount_info_set (info, "uri", uri_str);
-      
-      if (uri)
-        {
-          path = uri->path;
-          uri->path = NULL;
-          g_vfs_decoded_uri_free (uri);
-        }
     }
   else
     {
-      GDecodedUri *uri;
-
-      uri = g_vfs_decode_uri (uri_str);
-
-      if (uri == NULL)
-          return NULL;
-
       info = g_vfs_uri_mount_info_new ("dav");
       ssl = !g_ascii_strcasecmp (uri->scheme, "davs");
       g_vfs_uri_mount_info_set (info, "ssl", ssl ? "true" : "false");
 
       if (uri->host && *uri->host)
-          g_vfs_uri_mount_info_set (info, "host", uri->host);
+        g_vfs_uri_mount_info_set (info, "host", uri->host);
 
       if (uri->userinfo && *uri->userinfo)
-          g_vfs_uri_mount_info_set (info, "user", uri->userinfo);
+        g_vfs_uri_mount_info_set (info, "user", uri->userinfo);
 
       /* only set the port if it isn't the default port */
       if (uri->port != -1 && ! port_is_defaul_port (uri->port, ssl))
@@ -125,15 +111,12 @@
           g_vfs_uri_mount_info_set (info, "port", port);
           g_free (port);
         }
-
-      path = uri->path;
-      uri->path = NULL;
-      
-      g_vfs_decoded_uri_free (uri);
     }
 
+  info->path = uri->path;
+  uri->path = NULL;
+  g_vfs_decoded_uri_free (uri);
 
-  info->path = path;
   return info;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]