diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2012-12-28 14:51:02 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-12-30 10:49:44 -0800 |
commit | 39a1cb7ea739f3f869795da45f314bba6e0304a9 (patch) | |
tree | 9576635b53a60821de93a2152df17def244f67cd /gdbus | |
parent | de45bfaccc5979e6638a684aa2d79b5455b10ecc (diff) | |
download | connman-39a1cb7ea739f3f869795da45f314bba6e0304a9.tar.gz connman-39a1cb7ea739f3f869795da45f314bba6e0304a9.tar.bz2 connman-39a1cb7ea739f3f869795da45f314bba6e0304a9.zip |
gdbus: Check if the interface being registered is valid
This prevent registering interfaces that are empty or have all members
marked as experiemental.
Diffstat (limited to 'gdbus')
-rw-r--r-- | gdbus/object.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/gdbus/object.c b/gdbus/object.c index 24260584..c6bdd59e 100644 --- a/gdbus/object.c +++ b/gdbus/object.c @@ -1174,7 +1174,7 @@ static const GDBusSignalTable manager_signals[] = { { } }; -static void add_interface(struct generic_data *data, +static gboolean add_interface(struct generic_data *data, const char *name, const GDBusMethodTable *methods, const GDBusSignalTable *signals, @@ -1183,7 +1183,32 @@ static void add_interface(struct generic_data *data, GDBusDestroyFunction destroy) { struct interface_data *iface; + const GDBusMethodTable *method; + const GDBusSignalTable *signal; + const GDBusPropertyTable *property; + + for (method = methods; method && method->name; method++) { + if (!check_experimental(method->flags, + G_DBUS_METHOD_FLAG_EXPERIMENTAL)) + goto done; + } + + for (signal = signals; signal && signal->name; signal++) { + if (!check_experimental(signal->flags, + G_DBUS_SIGNAL_FLAG_EXPERIMENTAL)) + goto done; + } + + for (property = properties; property && property->name; property++) { + if (!check_experimental(property->flags, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL)) + goto done; + } + /* Nothing to register */ + return FALSE; + +done: iface = g_new0(struct interface_data, 1); iface->name = g_strdup(name); iface->methods = methods; @@ -1194,13 +1219,15 @@ static void add_interface(struct generic_data *data, data->interfaces = g_slist_append(data->interfaces, iface); if (data->parent == NULL) - return; + return TRUE; data->added = g_slist_append(data->added, iface); if (data->process_id > 0) - return; + return TRUE; data->process_id = g_idle_add(process_changes, data); + + return TRUE; } static struct generic_data *object_path_ref(DBusConnection *connection, @@ -1361,15 +1388,18 @@ gboolean g_dbus_register_interface(DBusConnection *connection, return FALSE; } + if (!add_interface(data, name, methods, signals, properties, user_data, + destroy)) { + object_path_unref(connection, path); + return FALSE; + } + if (properties != NULL && !find_interface(data->interfaces, DBUS_INTERFACE_PROPERTIES)) add_interface(data, DBUS_INTERFACE_PROPERTIES, properties_methods, properties_signals, NULL, data, NULL); - add_interface(data, name, methods, signals, properties, user_data, - destroy); - g_free(data->introspect); data->introspect = NULL; |