From bb396e0cff791f914d86a208eaa0a9b91be9d707 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 29 Mar 2011 17:05:04 +0100 Subject: [PATCH] DBusGProxy: link against GIO and use GDBus to check names' syntax Bug: https://bugs.freedesktop.org/show_bug.cgi?id=23616 --- configure.ac | 2 +- dbus/dbus-gproxy.c | 29 ++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 61522e5..27e8887 100644 --- a/configure.ac +++ b/configure.ac @@ -385,7 +385,7 @@ fi AC_SUBST(DBUS_DAEMONDIR) # Glib detection -PKG_CHECK_MODULES([DBUS_GLIB], [gobject-2.0 >= 2.26]) +PKG_CHECK_MODULES([DBUS_GLIB], [gobject-2.0 >= 2.26, gio-2.0 >= 2.26]) PKG_CHECK_MODULES(DBUS_GLIB_THREADS, gthread-2.0 >= 2.6, have_glib_threads=yes, have_glib_threads=no) AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes) diff --git a/dbus/dbus-gproxy.c b/dbus/dbus-gproxy.c index 0af05cc..10da697 100644 --- a/dbus/dbus-gproxy.c +++ b/dbus/dbus-gproxy.c @@ -32,6 +32,7 @@ #include #include #include +#include #define DBUS_G_PROXY_CALL_TO_ID(x) (GPOINTER_TO_UINT(x)) #define DBUS_G_PROXY_ID_TO_CALL(x) (GUINT_TO_POINTER(x)) @@ -1949,9 +1950,9 @@ dbus_g_proxy_new_for_name (DBusGConnection *connection, const char *interface_name) { g_return_val_if_fail (connection != NULL, NULL); - g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (g_dbus_is_name (name), NULL); g_return_val_if_fail (g_variant_is_object_path (path_name), NULL); - g_return_val_if_fail (interface_name != NULL, NULL); + g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL); return dbus_g_proxy_new (connection, name, path_name, interface_name); @@ -1993,9 +1994,9 @@ dbus_g_proxy_new_for_name_owner (DBusGConnection *connection, char *unique_name; g_return_val_if_fail (connection != NULL, NULL); - g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (g_dbus_is_name (name), NULL); g_return_val_if_fail (g_variant_is_object_path (path_name), NULL); - g_return_val_if_fail (interface_name != NULL, NULL); + g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL); if (!(unique_name = get_name_owner (DBUS_CONNECTION_FROM_G_CONNECTION (connection), name, error))) return NULL; @@ -2025,6 +2026,9 @@ dbus_g_proxy_new_from_proxy (DBusGProxy *proxy, DBusGProxyPrivate *priv; g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL); + g_return_val_if_fail (path == NULL || g_variant_is_object_path (path), NULL); + g_return_val_if_fail (interface == NULL || + g_dbus_is_interface_name (interface), NULL); priv = DBUS_G_PROXY_GET_PRIVATE(proxy); @@ -2061,7 +2065,7 @@ dbus_g_proxy_new_for_peer (DBusGConnection *connection, g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (g_variant_is_object_path (path_name), NULL); - g_return_val_if_fail (interface_name != NULL, NULL); + g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL); proxy = dbus_g_proxy_new (connection, NULL, path_name, interface_name); @@ -2137,8 +2141,11 @@ dbus_g_proxy_set_interface (DBusGProxy *proxy, const char *interface_name) { DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy); + g_return_if_fail (DBUS_IS_G_PROXY (proxy)); g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy)); + g_return_if_fail (g_dbus_is_interface_name (interface_name)); + /* FIXME - need to unregister when we switch interface for now * later should support idea of unset interface */ @@ -2476,6 +2483,7 @@ dbus_g_proxy_begin_call (DBusGProxy *proxy, g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL); g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), NULL); + g_return_val_if_fail (g_dbus_is_member_name (method), NULL); va_start (args, first_arg_type); @@ -2532,6 +2540,7 @@ dbus_g_proxy_begin_call_with_timeout (DBusGProxy *proxy, g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL); g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), NULL); + g_return_val_if_fail (g_dbus_is_member_name (method), NULL); g_return_val_if_fail (timeout >= 0 || timeout == -1, NULL); va_start (args, first_arg_type); @@ -2688,6 +2697,7 @@ dbus_g_proxy_call_with_timeout (DBusGProxy *proxy, g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), FALSE); g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), FALSE); + g_return_val_if_fail (g_dbus_is_member_name (method), FALSE); g_return_val_if_fail (timeout >= 0 || timeout == -1, FALSE); va_start (args, first_arg_type); @@ -2733,6 +2743,7 @@ dbus_g_proxy_call_no_reply (DBusGProxy *proxy, DBusGProxyPrivate *priv; g_return_if_fail (DBUS_IS_G_PROXY (proxy)); + g_return_if_fail (g_dbus_is_member_name (method)); g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy)); priv = DBUS_G_PROXY_GET_PRIVATE(proxy); @@ -2883,8 +2894,8 @@ dbus_g_proxy_add_signal (DBusGProxy *proxy, g_return_if_fail (DBUS_IS_G_PROXY (proxy)); g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy)); - g_return_if_fail (signal_name != NULL); - + g_return_if_fail (g_dbus_is_member_name (signal_name)); + priv = DBUS_G_PROXY_GET_PRIVATE(proxy); name = create_signal_name (priv->interface, signal_name); @@ -2946,7 +2957,7 @@ dbus_g_proxy_connect_signal (DBusGProxy *proxy, g_return_if_fail (DBUS_IS_G_PROXY (proxy)); g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy)); - g_return_if_fail (signal_name != NULL); + g_return_if_fail (g_dbus_is_member_name (signal_name)); g_return_if_fail (handler != NULL); priv = DBUS_G_PROXY_GET_PRIVATE(proxy); @@ -2998,7 +3009,7 @@ dbus_g_proxy_disconnect_signal (DBusGProxy *proxy, g_return_if_fail (DBUS_IS_G_PROXY (proxy)); g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy)); - g_return_if_fail (signal_name != NULL); + g_return_if_fail (g_dbus_is_member_name (signal_name)); g_return_if_fail (handler != NULL); priv = DBUS_G_PROXY_GET_PRIVATE(proxy); -- 1.7.4.1