From 4d0d1d74d4f40260a79161163b4b2f7276bce0b0 Mon Sep 17 00:00:00 2001
From: Sebastian Wick <sebastian.wick@redhat.com>
Date: Wed, 25 Feb 2026 04:33:50 +0100
Subject: [PATCH] Improve detection of eavesdrop=true

While in bus-broker, the eavesdrop match must follow the form of
`eavesdrop=[true|false]`, dbus-broker is more forgiving in its parsing
and also accepts `eavesdrop =[true|false]` and other whitespace (\t\r\n)
between `eavesdrop` and `=`. Let's make sure we also find those cases.
---
 flatpak-proxy.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/flatpak-proxy.c b/flatpak-proxy.c
index 1a354ef..10a6e03 100644
--- a/flatpak-proxy.c
+++ b/flatpak-proxy.c
@@ -2110,6 +2110,31 @@ get_arg0_string (Buffer *buffer)
   return NULL;
 }
 
+/* Matches against any "eavesdrop=", "eavesdrop =", etc. in str */
+static gboolean
+is_eavesdrop (const char *str)
+{
+  const char *e = str;
+
+  while (TRUE)
+    {
+      e = strstr (e, "eavesdrop");
+      if (e == NULL)
+        return FALSE;
+
+      e += strlen ("eavesdrop");
+
+      while (*e == ' '||
+             *e == '\t' ||
+             *e == '\n' ||
+             *e == '\r')
+        e++;
+
+      if (e[0] == '=')
+        return TRUE;
+    }
+}
+
 static gboolean
 validate_arg0_match (FlatpakProxyClient *client, Buffer *buffer)
 {
@@ -2117,15 +2142,13 @@ validate_arg0_match (FlatpakProxyClient *client, Buffer *buffer)
     g_dbus_message_new_from_blob (buffer->data, buffer->size, 0, NULL);
   GVariant *body;
   g_autoptr(GVariant) arg0 = NULL;
-  const char *match;
 
   if (message != NULL &&
       (body = g_dbus_message_get_body (message)) != NULL &&
       (arg0 = g_variant_get_child_value (body, 0)) != NULL &&
       g_variant_is_of_type (arg0, G_VARIANT_TYPE_STRING))
     {
-      match = g_variant_get_string (arg0, NULL);
-      if (strstr (match, "eavesdrop=") != NULL)
+      if (is_eavesdrop (g_variant_get_string (arg0, NULL)))
         return FALSE;
     }
 
-- 
2.53.0

