[glib: 1/3] gdbusobjectmanagerserver: Factor out child object path validation
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/3] gdbusobjectmanagerserver: Factor out child object path validation
- Date: Wed, 6 Oct 2021 12:03:36 +0000 (UTC)
commit 1c37f08004a1976a0bd4045020d7498090a85aea
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Oct 1 10:33:17 2021 +0100
gdbusobjectmanagerserver: Factor out child object path validation
This introduces no functional changes.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #2500
gio/gdbusobjectmanagerserver.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gio/gdbusobjectmanagerserver.c b/gio/gdbusobjectmanagerserver.c
index a68594765..8e5c03e11 100644
--- a/gio/gdbusobjectmanagerserver.c
+++ b/gio/gdbusobjectmanagerserver.c
@@ -457,6 +457,13 @@ registration_data_free (RegistrationData *data)
g_free (data);
}
+static gboolean
+is_valid_child_object_path (GDBusObjectManagerServer *manager,
+ const gchar *child_object_path)
+{
+ return g_str_has_prefix (child_object_path, manager->priv->object_path_ending_in_slash);
+}
+
/* ---------------------------------------------------------------------------------------------------- */
static void
@@ -471,7 +478,7 @@ g_dbus_object_manager_server_export_unlocked (GDBusObjectManagerServer *manager
g_return_if_fail (G_IS_DBUS_OBJECT_MANAGER_SERVER (manager));
g_return_if_fail (G_IS_DBUS_OBJECT (object));
- g_return_if_fail (g_str_has_prefix (object_path, manager->priv->object_path_ending_in_slash));
+ g_return_if_fail (is_valid_child_object_path (manager, object_path));
interface_names = g_ptr_array_new ();
@@ -574,7 +581,7 @@ g_dbus_object_manager_server_export_uniquely (GDBusObjectManagerServer *manager,
g_return_if_fail (G_IS_DBUS_OBJECT_MANAGER_SERVER (manager));
g_return_if_fail (G_IS_DBUS_OBJECT (object));
- g_return_if_fail (g_str_has_prefix (orig_object_path, manager->priv->object_path_ending_in_slash));
+ g_return_if_fail (is_valid_child_object_path (manager, orig_object_path));
g_mutex_lock (&manager->priv->lock);
@@ -650,7 +657,7 @@ g_dbus_object_manager_server_unexport_unlocked (GDBusObjectManagerServer *manag
g_return_val_if_fail (G_IS_DBUS_OBJECT_MANAGER_SERVER (manager), FALSE);
g_return_val_if_fail (g_variant_is_object_path (object_path), FALSE);
- g_return_val_if_fail (g_str_has_prefix (object_path, manager->priv->object_path_ending_in_slash), FALSE);
+ g_return_val_if_fail (is_valid_child_object_path (manager, object_path), FALSE);
ret = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]