summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-01-26 20:06:04 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-02-05 14:54:28 +0000
commitaaea59916398d1c590490edb0471a01bcf20e6d7 (patch)
treed3d228937fe10fb11f0ef84eff6b24bd532b07fe
parentdfc53a221fd9eb348b3fb66e44e22eef44f6588f (diff)
bus_driver_get_owner_of_name: factor out from bus_driver_get_conn_helper
We need this, or something equivalent, to address CVE-2015-0245 via code changes. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88811 Reviewed-by: Alban Crequy Reviewed-by: David King Reviewed-by: Philip Withnall
-rw-r--r--bus/driver.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/bus/driver.c b/bus/driver.c
index f5d3ebe2..9551f3d4 100644
--- a/bus/driver.c
+++ b/bus/driver.c
@@ -41,17 +41,32 @@
#include <string.h>
static DBusConnection *
+bus_driver_get_owner_of_name (DBusConnection *connection,
+ const char *name)
+{
+ BusRegistry *registry;
+ BusService *serv;
+ DBusString str;
+
+ registry = bus_connection_get_registry (connection);
+ _dbus_string_init_const (&str, name);
+ serv = bus_registry_lookup (registry, &str);
+
+ if (serv == NULL)
+ return NULL;
+
+ return bus_service_get_primary_owners_connection (serv);
+}
+
+static DBusConnection *
bus_driver_get_conn_helper (DBusConnection *connection,
DBusMessage *message,
const char *what_we_want,
const char **name_p,
DBusError *error)
{
- const char *name;
- BusRegistry *registry;
- BusService *serv;
- DBusString str;
DBusConnection *conn;
+ const char *name;
if (!dbus_message_get_args (message, error,
DBUS_TYPE_STRING, &name,
@@ -61,11 +76,9 @@ bus_driver_get_conn_helper (DBusConnection *connection,
_dbus_assert (name != NULL);
_dbus_verbose ("asked for %s of connection %s\n", what_we_want, name);
- registry = bus_connection_get_registry (connection);
- _dbus_string_init_const (&str, name);
- serv = bus_registry_lookup (registry, &str);
+ conn = bus_driver_get_owner_of_name (connection, name);
- if (serv == NULL)
+ if (conn == NULL)
{
dbus_set_error (error, DBUS_ERROR_NAME_HAS_NO_OWNER,
"Could not get %s of name '%s': no such name",
@@ -73,9 +86,6 @@ bus_driver_get_conn_helper (DBusConnection *connection,
return NULL;
}
- conn = bus_service_get_primary_owners_connection (serv);
- _dbus_assert (conn != NULL);
-
if (name_p != NULL)
*name_p = name;