From 6e18d05a0d7399f74084a29c378ea04373f0cb28 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 23 Oct 2013 15:45:15 +0100 Subject: [PATCH] gdbus: Ensure message matching always succeeds against path_namespace='/' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This copies the fix from upstream D-Bus bug https://bugs.freedesktop.org/show_bug.cgi?id=70799 to the GDBusDaemon implementation, ensuring that matching against path_namespace='/' succeeds for all keys (i.e. it’s a no-op). https://bugzilla.gnome.org/show_bug.cgi?id=710726 --- gio/gdbusdaemon.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gio/gdbusdaemon.c b/gio/gdbusdaemon.c index 23937710c..3631a9030 100644 --- a/gio/gdbusdaemon.c +++ b/gio/gdbusdaemon.c @@ -596,9 +596,18 @@ match_matches (GDBusDaemon *daemon, break; case CHECK_TYPE_PATH_PREFIX: len = strlen (element->value); - if (!(g_str_has_prefix (value, element->value) && - (value[len] == 0 || value[len] == '/'))) + + /* Make sure to handle the case of element->value == '/'. */ + if (len == 1) + break; + + /* Fail if there's no prefix match, or if the prefix match doesn't + * finish at the end of or at a separator in the @value. */ + if (!g_str_has_prefix (value, element->value)) return FALSE; + if (value[len] != 0 && value[len] != '/') + return FALSE; + break; case CHECK_TYPE_PATH_RELATED: len = strlen (element->value);