Rewrite DAV backend to libsoup async API to fix crashes

Resolves: #2062465
This commit is contained in:
Ondrej Holy 2022-04-08 14:02:50 +02:00
parent 73532ee75d
commit 4bdf3da7b0
3 changed files with 2598 additions and 1 deletions

View File

@ -0,0 +1,86 @@
From 4b9d9442f4b465e9403c4da399ccf6d7cc652eae Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <dkolesa@igalia.com>
Date: Sun, 27 Mar 2022 16:01:55 +0200
Subject: [PATCH] dav: Do not lose userinfo when copying URIs
The use of g_uri_build was also bad, since otherwise we would
run into this: https://gitlab.gnome.org/GNOME/glib/-/issues/2619
While this should be fixed in glib, we need to work around this
behavior for existing installations.
Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/614
---
daemon/gvfsbackenddav.c | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index f9d10a40..3ece9a5f 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -321,23 +321,6 @@ message_should_apply_redir_ref (SoupMessage *msg)
return TRUE;
}
-static GUri *
-dav_uri_dup_with (GUri *uri, const char *path, const char *userinfo)
-{
- if (!path && !userinfo)
- return g_uri_ref (uri);
-
- return g_uri_build (g_uri_get_flags (uri),
- g_uri_get_scheme (uri),
- userinfo ? userinfo : g_uri_get_userinfo (uri),
- g_uri_get_host (uri),
- g_uri_get_port (uri),
- path ? path : g_uri_get_path (uri),
- g_uri_get_query (uri),
- g_uri_get_fragment (uri));
-}
-
-
static GUri *
g_vfs_backend_dav_uri_for_path (GVfsBackend *backend,
const char *path,
@@ -369,7 +352,7 @@ g_vfs_backend_dav_uri_for_path (GVfsBackend *backend,
else
new_path = g_build_path ("/", g_uri_get_path (mount_base), fn_encoded, "/", NULL);
- uri = dav_uri_dup_with (mount_base, new_path, NULL);
+ uri = soup_uri_copy (mount_base, SOUP_URI_PATH, new_path, SOUP_URI_NONE);
g_free (fn_encoded);
g_free (new_path);
@@ -432,7 +415,10 @@ g_vfs_backend_dav_redirect (SoupSession *session,
}
tmp = new_uri;
- new_uri = dav_uri_dup_with (new_uri, NULL, g_uri_get_userinfo (old_uri));
+ new_uri = soup_uri_copy (new_uri,
+ SOUP_URI_USER, g_uri_get_user (old_uri),
+ SOUP_URI_AUTH_PARAMS, g_uri_get_auth_params (old_uri),
+ SOUP_URI_NONE);
g_uri_unref (tmp);
/* Check if this is a trailing slash redirect (i.e. /a/b to /a/b/),
@@ -2141,7 +2127,7 @@ do_mount (GVfsBackend *backend,
new_path = path_get_parent_dir (last_good_path);
tmp = mount_base;
- mount_base = dav_uri_dup_with (mount_base, new_path, NULL);
+ mount_base = soup_uri_copy (mount_base, SOUP_URI_PATH, new_path, SOUP_URI_NONE);
g_uri_unref (tmp);
G_VFS_BACKEND_HTTP (backend)->mount_base = mount_base;
@@ -2222,7 +2208,7 @@ do_mount (GVfsBackend *backend,
/* Set the working path in mount path */
tmp = mount_base;
- mount_base = dav_uri_dup_with (mount_base, last_good_path, NULL);
+ mount_base = soup_uri_copy (mount_base, SOUP_URI_PATH, last_good_path, SOUP_URI_NONE);
g_uri_unref (tmp);
G_VFS_BACKEND_HTTP (backend)->mount_base = mount_base;
g_free (last_good_path);
--
2.35.1

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@
Name: gvfs Name: gvfs
Version: 1.50.0 Version: 1.50.0
Release: 2%{?dist} Release: 3%{?dist}
Summary: Backends for the gio framework in GLib Summary: Backends for the gio framework in GLib
License: GPLv3 and LGPLv2+ and BSD and MPLv2.0 License: GPLv3 and LGPLv2+ and BSD and MPLv2.0
@ -32,6 +32,10 @@ Source0: https://download.gnome.org/sources/gvfs/1.50/gvfs-%{version}.tar.xz
# https://bugzilla.redhat.com/show_bug.cgi?id=2066717 # https://bugzilla.redhat.com/show_bug.cgi?id=2066717
Patch0: dav-Fix-crashes-caused-by-extra-unref.patch Patch0: dav-Fix-crashes-caused-by-extra-unref.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2062465
Patch1: dav-Do-not-lose-userinfo-when-copying-URIs.patch
Patch2: dav-Rewrite-to-libsoup-async-API-to-fix-crashes.patch
BuildRequires: meson BuildRequires: meson
BuildRequires: gcc BuildRequires: gcc
BuildRequires: pkgconfig(glib-2.0) >= %{glib2_version} BuildRequires: pkgconfig(glib-2.0) >= %{glib2_version}
@ -424,6 +428,9 @@ killall -USR1 gvfsd >&/dev/null || :
%{_datadir}/installed-tests %{_datadir}/installed-tests
%changelog %changelog
* Fri Apr 8 2022 Ondrej Holy <oholy@redhat.com> - 1.50.0-3
- Rewrite DAV backend to libsoup async API to fix crashes (#2062465)
* Thu Mar 24 2022 Ondrej Holy <oholy@redhat.com> - 1.50.0-2 * Thu Mar 24 2022 Ondrej Holy <oholy@redhat.com> - 1.50.0-2
- Fix DAV backend crashes caused by extra unref (#2066717) - Fix DAV backend crashes caused by extra unref (#2066717)