|
|
8d3db5 |
From 865b204f1c06b782cf7b4a479b358e76f4b3dfee Mon Sep 17 00:00:00 2001
|
|
|
8d3db5 |
From: fujiwarat <takao.fujiwara1@gmail.com>
|
|
|
8d3db5 |
Date: Tue, 17 Jul 2018 13:39:30 +0900
|
|
|
8d3db5 |
Subject: [PATCH] bus: Fix SEGV in bus_panel_proxy_focus_in()
|
|
|
8d3db5 |
|
|
|
8d3db5 |
BUG=rhbz#1349148
|
|
|
8d3db5 |
BUG=rhbz#1385349
|
|
|
8d3db5 |
BUG=rhbz#1350291
|
|
|
8d3db5 |
BUG=rhbz#1406699
|
|
|
8d3db5 |
BUG=rhbz#1432252
|
|
|
8d3db5 |
BUG=rhbz#1601577
|
|
|
8d3db5 |
---
|
|
|
8d3db5 |
bus/dbusimpl.c | 38 ++++++++++++++++++++++++++++++++------
|
|
|
8d3db5 |
bus/engineproxy.c | 5 ++++-
|
|
|
8d3db5 |
bus/ibusimpl.c | 21 ++++++++++++++++++---
|
|
|
8d3db5 |
3 files changed, 54 insertions(+), 10 deletions(-)
|
|
|
8d3db5 |
|
|
|
8d3db5 |
diff --git a/bus/dbusimpl.c b/bus/dbusimpl.c
|
|
|
8d3db5 |
index b54ef817..e4dd8683 100644
|
|
|
8d3db5 |
--- a/bus/dbusimpl.c
|
|
|
8d3db5 |
+++ b/bus/dbusimpl.c
|
|
|
8d3db5 |
@@ -2,7 +2,8 @@
|
|
|
8d3db5 |
/* vim:set et sts=4: */
|
|
|
8d3db5 |
/* ibus - The Input Bus
|
|
|
8d3db5 |
* Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
|
|
|
8d3db5 |
- * Copyright (C) 2008-2013 Red Hat, Inc.
|
|
|
8d3db5 |
+ * Copyright (C) 2015-2017 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
|
|
8d3db5 |
+ * Copyright (C) 2008-2017 Red Hat, Inc.
|
|
|
8d3db5 |
*
|
|
|
8d3db5 |
* This library is free software; you can redistribute it and/or
|
|
|
8d3db5 |
* modify it under the terms of the GNU Lesser General Public
|
|
|
8d3db5 |
@@ -344,6 +345,8 @@ bus_name_service_set_primary_owner (BusNameService *service,
|
|
|
8d3db5 |
BusConnectionOwner *owner,
|
|
|
8d3db5 |
BusDBusImpl *dbus)
|
|
|
8d3db5 |
{
|
|
|
8d3db5 |
+ gboolean has_old_owner = FALSE;
|
|
|
8d3db5 |
+
|
|
|
8d3db5 |
g_assert (service != NULL);
|
|
|
8d3db5 |
g_assert (owner != NULL);
|
|
|
8d3db5 |
g_assert (dbus != NULL);
|
|
|
8d3db5 |
@@ -351,6 +354,13 @@ bus_name_service_set_primary_owner (BusNameService *service,
|
|
|
8d3db5 |
BusConnectionOwner *old = service->owners != NULL ?
|
|
|
8d3db5 |
(BusConnectionOwner *)service->owners->data : NULL;
|
|
|
8d3db5 |
|
|
|
8d3db5 |
+ /* rhbz#1432252 If bus_connection_get_unique_name() == NULL,
|
|
|
8d3db5 |
+ * "Hello" method is not received yet.
|
|
|
8d3db5 |
+ */
|
|
|
8d3db5 |
+ if (old != NULL && bus_connection_get_unique_name (old->conn) != NULL) {
|
|
|
8d3db5 |
+ has_old_owner = TRUE;
|
|
|
8d3db5 |
+ }
|
|
|
8d3db5 |
+
|
|
|
8d3db5 |
if (old != NULL) {
|
|
|
8d3db5 |
g_signal_emit (dbus,
|
|
|
8d3db5 |
dbus_signals[NAME_LOST],
|
|
|
8d3db5 |
@@ -370,7 +380,8 @@ bus_name_service_set_primary_owner (BusNameService *service,
|
|
|
8d3db5 |
0,
|
|
|
8d3db5 |
owner->conn,
|
|
|
8d3db5 |
service->name,
|
|
|
8d3db5 |
- old != NULL ? bus_connection_get_unique_name (old->conn) : "",
|
|
|
8d3db5 |
+ has_old_owner ? bus_connection_get_unique_name (old->conn) :
|
|
|
8d3db5 |
+ "",
|
|
|
8d3db5 |
bus_connection_get_unique_name (owner->conn));
|
|
|
8d3db5 |
|
|
|
8d3db5 |
if (old != NULL && old->do_not_queue != 0) {
|
|
|
8d3db5 |
@@ -427,6 +438,7 @@ bus_name_service_remove_owner (BusNameService *service,
|
|
|
8d3db5 |
BusDBusImpl *dbus)
|
|
|
8d3db5 |
{
|
|
|
8d3db5 |
GSList *owners;
|
|
|
8d3db5 |
+ gboolean has_new_owner = FALSE;
|
|
|
8d3db5 |
|
|
|
8d3db5 |
g_assert (service != NULL);
|
|
|
8d3db5 |
g_assert (owner != NULL);
|
|
|
8d3db5 |
@@ -439,6 +451,13 @@ bus_name_service_remove_owner (BusNameService *service,
|
|
|
8d3db5 |
BusConnectionOwner *_new = NULL;
|
|
|
8d3db5 |
if (owners->next != NULL) {
|
|
|
8d3db5 |
_new = (BusConnectionOwner *)owners->next->data;
|
|
|
8d3db5 |
+ /* rhbz#1406699 If bus_connection_get_unique_name() == NULL,
|
|
|
8d3db5 |
+ * "Hello" method is not received yet.
|
|
|
8d3db5 |
+ */
|
|
|
8d3db5 |
+ if (_new != NULL &&
|
|
|
8d3db5 |
+ bus_connection_get_unique_name (_new->conn) != NULL) {
|
|
|
8d3db5 |
+ has_new_owner = TRUE;
|
|
|
8d3db5 |
+ }
|
|
|
8d3db5 |
}
|
|
|
8d3db5 |
|
|
|
8d3db5 |
if (dbus != NULL) {
|
|
|
8d3db5 |
@@ -447,7 +466,7 @@ bus_name_service_remove_owner (BusNameService *service,
|
|
|
8d3db5 |
0,
|
|
|
8d3db5 |
owner->conn,
|
|
|
8d3db5 |
service->name);
|
|
|
8d3db5 |
- if (_new != NULL) {
|
|
|
8d3db5 |
+ if (has_new_owner) {
|
|
|
8d3db5 |
g_signal_emit (dbus,
|
|
|
8d3db5 |
dbus_signals[NAME_ACQUIRED],
|
|
|
8d3db5 |
0,
|
|
|
8d3db5 |
@@ -460,7 +479,7 @@ bus_name_service_remove_owner (BusNameService *service,
|
|
|
8d3db5 |
_new != NULL ? _new->conn : NULL,
|
|
|
8d3db5 |
service->name,
|
|
|
8d3db5 |
bus_connection_get_unique_name (owner->conn),
|
|
|
8d3db5 |
- _new != NULL ? bus_connection_get_unique_name (_new->conn) : "");
|
|
|
8d3db5 |
+ has_new_owner ? bus_connection_get_unique_name (_new->conn) : "");
|
|
|
8d3db5 |
|
|
|
8d3db5 |
}
|
|
|
8d3db5 |
}
|
|
|
8d3db5 |
@@ -1464,13 +1483,20 @@ bus_dbus_impl_connection_filter_cb (GDBusConnection *dbus_connection,
|
|
|
8d3db5 |
gboolean incoming,
|
|
|
8d3db5 |
gpointer user_data)
|
|
|
8d3db5 |
{
|
|
|
8d3db5 |
+ BusDBusImpl *dbus;
|
|
|
8d3db5 |
+ BusConnection *connection;
|
|
|
8d3db5 |
+
|
|
|
8d3db5 |
g_assert (G_IS_DBUS_CONNECTION (dbus_connection));
|
|
|
8d3db5 |
g_assert (G_IS_DBUS_MESSAGE (message));
|
|
|
8d3db5 |
g_assert (BUS_IS_DBUS_IMPL (user_data));
|
|
|
8d3db5 |
|
|
|
8d3db5 |
- BusDBusImpl *dbus = (BusDBusImpl *) user_data;
|
|
|
8d3db5 |
- BusConnection *connection = bus_connection_lookup (dbus_connection);
|
|
|
8d3db5 |
+ if (g_dbus_connection_is_closed (dbus_connection))
|
|
|
8d3db5 |
+ return NULL;
|
|
|
8d3db5 |
+
|
|
|
8d3db5 |
+ dbus = (BusDBusImpl *) user_data;
|
|
|
8d3db5 |
+ connection = bus_connection_lookup (dbus_connection);
|
|
|
8d3db5 |
g_assert (connection != NULL);
|
|
|
8d3db5 |
+ g_assert (BUS_IS_CONNECTION (connection));
|
|
|
8d3db5 |
|
|
|
8d3db5 |
if (incoming) {
|
|
|
8d3db5 |
/* is incoming message */
|
|
|
8d3db5 |
diff --git a/bus/engineproxy.c b/bus/engineproxy.c
|
|
|
8d3db5 |
index 2d98995c..d661673a 100644
|
|
|
8d3db5 |
--- a/bus/engineproxy.c
|
|
|
8d3db5 |
+++ b/bus/engineproxy.c
|
|
|
8d3db5 |
@@ -665,6 +665,7 @@ bus_engine_proxy_new_internal (const gchar *path,
|
|
|
8d3db5 |
IBusEngineDesc *desc,
|
|
|
8d3db5 |
GDBusConnection *connection)
|
|
|
8d3db5 |
{
|
|
|
8d3db5 |
+ GError *error = NULL;
|
|
|
8d3db5 |
g_assert (path);
|
|
|
8d3db5 |
g_assert (IBUS_IS_ENGINE_DESC (desc));
|
|
|
8d3db5 |
g_assert (G_IS_DBUS_CONNECTION (connection));
|
|
|
8d3db5 |
@@ -673,7 +674,7 @@ bus_engine_proxy_new_internal (const gchar *path,
|
|
|
8d3db5 |
BusEngineProxy *engine =
|
|
|
8d3db5 |
(BusEngineProxy *) g_initable_new (BUS_TYPE_ENGINE_PROXY,
|
|
|
8d3db5 |
NULL,
|
|
|
8d3db5 |
- NULL,
|
|
|
8d3db5 |
+ &error,
|
|
|
8d3db5 |
"desc", desc,
|
|
|
8d3db5 |
"g-connection", connection,
|
|
|
8d3db5 |
"g-interface-name", IBUS_INTERFACE_ENGINE,
|
|
|
8d3db5 |
@@ -681,6 +682,8 @@ bus_engine_proxy_new_internal (const gchar *path,
|
|
|
8d3db5 |
"g-default-timeout", g_gdbus_timeout,
|
|
|
8d3db5 |
"g-flags", flags,
|
|
|
8d3db5 |
NULL);
|
|
|
8d3db5 |
+ /* FIXME: rhbz#1601577 */
|
|
|
8d3db5 |
+ g_assert_no_error (error);
|
|
|
8d3db5 |
const gchar *layout = ibus_engine_desc_get_layout (desc);
|
|
|
8d3db5 |
if (layout != NULL && layout[0] != '\0') {
|
|
|
8d3db5 |
engine->keymap = ibus_keymap_get (layout);
|
|
|
8d3db5 |
diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c
|
|
|
8d3db5 |
index ec1caea8..9ae3751b 100644
|
|
|
8d3db5 |
--- a/bus/ibusimpl.c
|
|
|
8d3db5 |
+++ b/bus/ibusimpl.c
|
|
|
8d3db5 |
@@ -484,13 +484,16 @@ _dbus_name_owner_changed_cb (BusDBusImpl *dbus,
|
|
|
8d3db5 |
else if (!g_strcmp0 (name, IBUS_SERVICE_PANEL_EXTENSION_EMOJI))
|
|
|
8d3db5 |
panel_type = PANEL_TYPE_EXTENSION_EMOJI;
|
|
|
8d3db5 |
|
|
|
8d3db5 |
- if (panel_type != PANEL_TYPE_NONE) {
|
|
|
8d3db5 |
+ do {
|
|
|
8d3db5 |
+ if (panel_type == PANEL_TYPE_NONE)
|
|
|
8d3db5 |
+ break;
|
|
|
8d3db5 |
if (g_strcmp0 (new_name, "") != 0) {
|
|
|
8d3db5 |
/* a Panel process is started. */
|
|
|
8d3db5 |
BusConnection *connection;
|
|
|
8d3db5 |
BusInputContext *context = NULL;
|
|
|
8d3db5 |
BusPanelProxy **panel = (panel_type == PANEL_TYPE_PANEL) ?
|
|
|
8d3db5 |
&ibus->panel : &ibus->emoji_extension;
|
|
|
8d3db5 |
+ GDBusConnection *dbus_connection = NULL;
|
|
|
8d3db5 |
|
|
|
8d3db5 |
if (*panel != NULL) {
|
|
|
8d3db5 |
ibus_proxy_destroy ((IBusProxy *)(*panel));
|
|
|
8d3db5 |
@@ -499,9 +502,21 @@ _dbus_name_owner_changed_cb (BusDBusImpl *dbus,
|
|
|
8d3db5 |
g_assert (*panel == NULL);
|
|
|
8d3db5 |
}
|
|
|
8d3db5 |
|
|
|
8d3db5 |
- connection = bus_dbus_impl_get_connection_by_name (BUS_DEFAULT_DBUS, new_name);
|
|
|
8d3db5 |
+ connection = bus_dbus_impl_get_connection_by_name (BUS_DEFAULT_DBUS,
|
|
|
8d3db5 |
+ new_name);
|
|
|
8d3db5 |
g_return_if_fail (connection != NULL);
|
|
|
8d3db5 |
|
|
|
8d3db5 |
+ dbus_connection = bus_connection_get_dbus_connection (connection);
|
|
|
8d3db5 |
+ /* rhbz#1349148 rhbz#1385349
|
|
|
8d3db5 |
+ * Avoid SEGV of BUS_IS_PANEL_PROXY (ibus->panel)
|
|
|
8d3db5 |
+ * This function is called during destroying the connection
|
|
|
8d3db5 |
+ * in this case? */
|
|
|
8d3db5 |
+ if (dbus_connection == NULL ||
|
|
|
8d3db5 |
+ g_dbus_connection_is_closed (dbus_connection)) {
|
|
|
8d3db5 |
+ new_name = "";
|
|
|
8d3db5 |
+ break;
|
|
|
8d3db5 |
+ }
|
|
|
8d3db5 |
+
|
|
|
8d3db5 |
*panel = bus_panel_proxy_new (connection, panel_type);
|
|
|
8d3db5 |
if (panel_type == PANEL_TYPE_EXTENSION_EMOJI)
|
|
|
8d3db5 |
ibus->enable_emoji_extension = FALSE;
|
|
|
8d3db5 |
@@ -555,7 +570,7 @@ _dbus_name_owner_changed_cb (BusDBusImpl *dbus,
|
|
|
8d3db5 |
}
|
|
|
8d3db5 |
}
|
|
|
8d3db5 |
}
|
|
|
8d3db5 |
- }
|
|
|
8d3db5 |
+ } while (0);
|
|
|
8d3db5 |
|
|
|
8d3db5 |
bus_ibus_impl_component_name_owner_changed (ibus, name, old_name, new_name);
|
|
|
8d3db5 |
}
|
|
|
8d3db5 |
--
|
|
|
8d3db5 |
2.17.1
|
|
|
8d3db5 |
|