mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-05 09:58:07 +02:00
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
This commit is contained in:
parent
dfc53a221f
commit
aaea599163
1 changed files with 21 additions and 11 deletions
32
bus/driver.c
32
bus/driver.c
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue