Commit aaea5991 authored by Simon McVittie's avatar Simon McVittie

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
parent dfc53a22
......@@ -40,6 +40,24 @@
#include <dbus/dbus-marshal-recursive.h>
#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,
......@@ -47,11 +65,8 @@ bus_driver_get_conn_helper (DBusConnection *connection,
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment