aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2022-02-28 12:58:30 -0500
committerScott Murray <scott.murray@konsulko.com>2022-02-28 18:03:10 +0000
commitd2377cec23dca4b8caab2208767bc23de32ae807 (patch)
tree6efd4a8e565d2e1cef75fc4749cf2b3a70d8e9d0
parent5d094ec17f0f60489efe9df6c113be62f80b4c2a (diff)
Added logic in the D-Bus signal callbacks to be paranoid about the input to the callback, as it became clear from debugging that having two different libraries use g_dbus_connection_signal_subscribe in the same process results in the separately registered callbacks all getting called with the superset of the filtered signal requests. At best this leads to confusion with respect to logging/debugging, at worst it opens the door to tripping over unexpected inputs in the callbacks. Bug-AGL: SPEC-4182 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I86a804917c5f31f4c94e3e642728f7e0df5dd2e4
-rw-r--r--src/api.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/api.c b/src/api.c
index b9582e4..07bbc70 100644
--- a/src/api.c
+++ b/src/api.c
@@ -231,6 +231,16 @@ static void connman_manager_signal_callback(GDBusConnection *connection,
DEBUG("parameters = %s", g_variant_print(parameters, TRUE));
#endif
+ // Be paranoid to avoid any potential issues from unexpected signals,
+ // as glib seems to do some unexpected reuse of the D-Bus signal
+ // mechanism if there is more than one subscriber in the same process,
+ // and we will see signals we did not register for. :(
+ if (!(g_strcmp0(object_path, "/") == 0 &&
+ g_strcmp0(interface_name, "net.connman.Manager") == 0)) {
+ // Not an expected signal
+ return;
+ }
+
if (!g_strcmp0(signal_name, "TechnologyAdded")) {
g_variant_get(parameters, "(&o@a{sv})", &path, &var);
basename = connman_strip_path(path);
@@ -311,6 +321,16 @@ static void connman_technology_signal_callback(GDBusConnection *connection,
DEBUG("parameters = %s", g_variant_print(parameters, TRUE));
#endif
+ // Be paranoid to avoid any potential issues from unexpected signals,
+ // as glib seems to do some unexpected reuse of the D-Bus signal
+ // mechanism if there is more than one subscriber in the same process,
+ // and we will see signals we did not register for. :(
+ if (!(g_str_has_prefix(object_path, "/net/connman/technology/") &&
+ g_strcmp0(interface_name, "net.connman.Technology") == 0)) {
+ // Not an expected signal
+ return;
+ }
+
// a basename must exist and be at least 1 character wide
const gchar *basename = connman_strip_path(object_path);
g_assert(basename);
@@ -339,6 +359,16 @@ static void connman_service_signal_callback(GDBusConnection *connection,
DEBUG("parameters = %s", g_variant_print(parameters, TRUE));
#endif
+ // Be paranoid to avoid any potential issues from unexpected signals,
+ // as glib seems to do some unexpected reuse of the D-Bus signal
+ // mechanism if there is more than one subscriber in the same process,
+ // and we will see signals we did not register for. :(
+ if (!(g_str_has_prefix(object_path, "/net/connman/service/") &&
+ g_strcmp0(interface_name, "net.connman.Service") == 0)) {
+ // Not an expected signal
+ return;
+ }
+
// a basename must exist and be at least 1 character wide
const gchar *basename = connman_strip_path(object_path);
g_assert(basename);