diff options
author | Scott Murray <scott.murray@konsulko.com> | 2022-02-28 12:58:30 -0500 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2022-02-28 18:03:10 +0000 |
commit | d2377cec23dca4b8caab2208767bc23de32ae807 (patch) | |
tree | 6efd4a8e565d2e1cef75fc4749cf2b3a70d8e9d0 | |
parent | 5d094ec17f0f60489efe9df6c113be62f80b4c2a (diff) |
Be paranoid in D-Bus signal callbacksneedlefish_13.93.0needlefish/13.93.0marlin_12.93.0marlin/12.93.0lamprey_12.1.6lamprey_12.1.5lamprey_12.1.4lamprey_12.1.3lamprey_12.1.2lamprey/12.1.6lamprey/12.1.5lamprey/12.1.4lamprey/12.1.3lamprey/12.1.213.93.012.93.012.1.612.1.512.1.412.1.312.1.2
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.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -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); |