[telepathy-mission-control/master] fd.o #21034: McdDispatcher: in CreateChannel and EnsureChannel, validate Client name

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Apr 7 05:04:04 PDT 2009


The spec says we should, and it's easy to do.
---
 src/mcd-dispatcher.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index a95c865..01135e2 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -3539,8 +3539,23 @@ dispatcher_request_channel (McdDispatcher *self,
         goto despair;
     }
 
-    /* FIXME: raise InvalidArgument if preferred_handler is syntactically
-     * invalid or does not start with the right thing */
+    if (!tp_dbus_check_valid_bus_name (preferred_handler,
+                                       TP_DBUS_NAME_TYPE_WELL_KNOWN,
+                                       &error))
+    {
+        /* The error is TP_DBUS_ERROR_INVALID_BUS_NAME, which has no D-Bus
+         * representation; re-map to InvalidArgument. */
+        error->domain = TP_ERRORS;
+        error->code = TP_ERROR_INVALID_ARGUMENT;
+        goto despair;
+    }
+
+    if (!g_str_has_prefix (preferred_handler, MC_CLIENT_BUS_NAME_BASE))
+    {
+        g_set_error (&error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+                     "Not a Telepathy Client: %s", preferred_handler);
+        goto despair;
+    }
 
     channel = _mcd_account_create_request (account, requested_properties,
                                            user_action_time, preferred_handler,
-- 
1.5.6.5




More information about the telepathy-commits mailing list