diff options
author | Ondrej Holy <oholy@redhat.com> | 2016-10-13 12:34:14 +0200 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2016-11-18 16:23:26 +0100 |
commit | 7368e4831d470c24e1431558b251e53ca0926ba5 (patch) | |
tree | a1dc1cba5d6cd4158709fed515d647b0c84810ef /daemon/gvfsbackenddnssd.c | |
parent | ccf7b9181d322f30979b6245d046d13615e6b1c7 (diff) | |
download | gvfs-7368e4831d470c24e1431558b251e53ca0926ba5.tar.gz |
dnssd: Free resolvers also on client failure
Resolvers are not currently removed on client failure. It might
potentialy lead to some use-after-free crashes. Remove resolver
objects also on client failures.
https://bugzilla.gnome.org/show_bug.cgi?id=631023
Diffstat (limited to 'daemon/gvfsbackenddnssd.c')
-rw-r--r-- | daemon/gvfsbackenddnssd.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/daemon/gvfsbackenddnssd.c b/daemon/gvfsbackenddnssd.c index e3f33189..f359bac9 100644 --- a/daemon/gvfsbackenddnssd.c +++ b/daemon/gvfsbackenddnssd.c @@ -140,6 +140,7 @@ G_DEFINE_TYPE (GVfsBackendDnsSd, g_vfs_backend_dns_sd, G_VFS_TYPE_BACKEND) static void add_browsers (GVfsBackendDnsSd *backend); static void remove_browsers (GVfsBackendDnsSd *backend); +static void remove_resolvers (GVfsBackendDnsSd *backend); static AvahiClient *get_global_avahi_client (void); /* Callback for state changes on the Client */ @@ -157,7 +158,8 @@ avahi_client_callback (AvahiClient *client, AvahiClientState state, void *userda { /* Remove the service browsers from the handles */ g_list_foreach (dnssd_backends, (GFunc)remove_browsers, NULL); - + g_list_foreach (dnssd_backends, (GFunc)remove_resolvers, NULL); + /* Destroy old client */ avahi_client_free (client); global_client = NULL; @@ -702,6 +704,13 @@ remove_browsers (GVfsBackendDnsSd *backend) backend->browsers = NULL; } +static void +remove_resolvers (GVfsBackendDnsSd *backend) +{ + g_list_free_full (backend->resolvers, (GDestroyNotify)avahi_service_resolver_free); + backend->resolvers = NULL; +} + static gboolean try_mount (GVfsBackend *backend, GVfsJobMount *job, @@ -802,7 +811,7 @@ g_vfs_backend_dns_sd_finalize (GObject *object) dnssd_backends = g_list_remove (dnssd_backends, backend); remove_browsers (backend); - g_list_free_full (backend->resolvers, (GDestroyNotify)avahi_service_resolver_free); + remove_resolvers (backend); if (dnssd_backends == NULL && global_client) { |