[gnome-settings-daemon/gnome-3-18] datetime: Fix possible use-after-free when calls are cancelled
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/gnome-3-18] datetime: Fix possible use-after-free when calls are cancelled
- Date: Wed, 16 Mar 2016 11:23:54 +0000 (UTC)
commit 7738d3396531d59686bbd173b265c11cea65b3bd
Author: Bastien Nocera <hadess hadess net>
Date: Wed Mar 16 12:22:21 2016 +0100
datetime: Fix possible use-after-free when calls are cancelled
1) Don't use the possibly dangling user_data when the calls might
have been cancelled
2) Don't print warnings when calls were cancelled
3) Don't print criticals for run-time warnings
https://bugzilla.gnome.org/show_bug.cgi?id=763689
plugins/datetime/gsd-timezone-monitor.c | 40 +++++++++++++++++++++----------
1 files changed, 27 insertions(+), 13 deletions(-)
---
diff --git a/plugins/datetime/gsd-timezone-monitor.c b/plugins/datetime/gsd-timezone-monitor.c
index 689f281..ba021ba 100644
--- a/plugins/datetime/gsd-timezone-monitor.c
+++ b/plugins/datetime/gsd-timezone-monitor.c
@@ -62,18 +62,20 @@ set_timezone_cb (GObject *source,
GAsyncResult *res,
gpointer user_data)
{
- GsdTimezoneMonitor *self = user_data;
- GsdTimezoneMonitorPrivate *priv = gsd_timezone_monitor_get_instance_private (self);
+ GsdTimezoneMonitorPrivate *priv;
GError *error = NULL;
- if (!timedate1_call_set_timezone_finish (priv->dtm,
+ if (!timedate1_call_set_timezone_finish (TIMEDATE1 (source),
res,
&error)) {
- g_warning ("Could not set system timezone: %s", error->message);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Could not set system timezone: %s", error->message);
g_error_free (error);
return;
}
+ priv = gsd_timezone_monitor_get_instance_private (user_data);
+
g_signal_emit (G_OBJECT (self),
signals[TIMEZONE_CHANGED],
0, priv->current_timezone);
@@ -233,7 +235,8 @@ on_reverse_geocoding_ready (GObject *source_object,
res,
&error);
if (error != NULL) {
- g_debug ("Reverse geocoding failed: %s", error->message);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_debug ("Reverse geocoding failed: %s", error->message);
g_error_free (error);
return;
}
@@ -279,7 +282,8 @@ on_location_proxy_ready (GObject *source_object,
location = geoclue_location_proxy_new_for_bus_finish (res, &error);
if (error != NULL) {
- g_critical ("Failed to connect to GeoClue2 service: %s", error->message);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to connect to GeoClue2 service: %s", error->message);
g_error_free (error);
return;
}
@@ -320,7 +324,8 @@ on_start_ready (GObject *source_object,
if (!geoclue_client_call_start_finish (GEOCLUE_CLIENT (source_object),
res,
&error)) {
- g_critical ("Failed to start GeoClue2 client: %s", error->message);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to start GeoClue2 client: %s", error->message);
g_error_free (error);
return;
}
@@ -333,15 +338,18 @@ on_client_proxy_ready (GObject *source_object,
{
GError *error = NULL;
GsdTimezoneMonitor *self = user_data;
- GsdTimezoneMonitorPrivate *priv = gsd_timezone_monitor_get_instance_private (self);
+ GsdTimezoneMonitorPrivate *priv;
priv->geoclue_client = geoclue_client_proxy_new_for_bus_finish (res, &error);
if (error != NULL) {
- g_critical ("Failed to connect to GeoClue2 service: %s", error->message);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to connect to GeoClue2 service: %s", error->message);
g_error_free (error);
return;
}
+ priv = gsd_timezone_monitor_get_instance_private (self);
+
geoclue_client_set_desktop_id (priv->geoclue_client, DESKTOP_ID);
geoclue_client_set_distance_threshold (priv->geoclue_client,
GEOCODE_LOCATION_ACCURACY_CITY);
@@ -365,17 +373,20 @@ on_get_client_ready (GObject *source_object,
gchar *client_path;
GError *error = NULL;
GsdTimezoneMonitor *self = user_data;
- GsdTimezoneMonitorPrivate *priv = gsd_timezone_monitor_get_instance_private (self);
+ GsdTimezoneMonitorPrivate *priv;
if (!geoclue_manager_call_get_client_finish (GEOCLUE_MANAGER (source_object),
&client_path,
res,
&error)) {
- g_critical ("Failed to connect to GeoClue2 service: %s", error->message);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to connect to GeoClue2 service: %s", error->message);
g_error_free (error);
return;
}
+ priv = gsd_timezone_monitor_get_instance_private (self);
+
geoclue_client_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.GeoClue2",
@@ -393,15 +404,18 @@ on_manager_proxy_ready (GObject *source_object,
GError *error = NULL;
GsdTimezoneMonitor *self = user_data;
- GsdTimezoneMonitorPrivate *priv = gsd_timezone_monitor_get_instance_private (self);
+ GsdTimezoneMonitorPrivate *priv;
priv->geoclue_manager = geoclue_manager_proxy_new_for_bus_finish (res, &error);
if (error != NULL) {
- g_critical ("Failed to connect to GeoClue2 service: %s", error->message);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to connect to GeoClue2 service: %s", error->message);
g_error_free (error);
return;
}
+ priv = gsd_timezone_monitor_get_instance_private (self);
+
geoclue_manager_call_get_client (priv->geoclue_manager,
priv->cancellable,
on_get_client_ready,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]