gdbus: Properly fix encoding of double arrays
[platform/upstream/glib.git] / gio / gdbusdaemon.c
index 96db54d..3631a90 100644 (file)
@@ -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);
@@ -1346,6 +1355,7 @@ handle_start_service_by_name (_GFreedesktopDBus *object,
   return TRUE;
 }
 
+G_GNUC_PRINTF(5, 6)
 static void
 return_error (Client *client, GDBusMessage *message,
              GQuark                 domain,
@@ -1523,7 +1533,6 @@ on_authorize_authenticated_peer (GDBusAuthObserver *observer,
                                 GCredentials      *credentials,
                                 gpointer           user_data)
 {
-  GDBusDaemon *daemon = user_data;
   gboolean authorized = TRUE;
 
   if (credentials != NULL)