Merge branch 'leak-fixes-33126'

Reviewed-by: Colin Walters <walters@verbum.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33126
This commit is contained in:
Simon McVittie 2011-02-17 17:19:13 +00:00
commit a4102ba51f
2 changed files with 42 additions and 35 deletions

View file

@ -264,6 +264,7 @@ update_desktop_file_entry (BusActivation *activation,
DBusStat stat_buf;
DBusString file_path;
DBusError tmp_error;
dbus_bool_t retval;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
@ -286,14 +287,14 @@ update_desktop_file_entry (BusActivation *activation,
!_dbus_concat_dir_and_file (&file_path, filename))
{
BUS_SET_OOM (error);
goto failed;
goto out;
}
if (!_dbus_stat (&file_path, &stat_buf, NULL))
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Can't stat the service file\n");
goto failed;
goto out;
}
if (!bus_desktop_file_get_string (desktop_file,
@ -301,14 +302,18 @@ update_desktop_file_entry (BusActivation *activation,
DBUS_SERVICE_NAME,
&name,
error))
goto failed;
goto out;
if (!bus_desktop_file_get_string (desktop_file,
DBUS_SERVICE_SECTION,
DBUS_SERVICE_EXEC,
&exec_tmp,
error))
goto failed;
goto out;
exec = _dbus_strdup (_dbus_replace_install_prefix (exec_tmp));
dbus_free (exec_tmp);
exec_tmp = NULL;
/* user is not _required_ unless we are using system activation */
if (!bus_desktop_file_get_string (desktop_file,
@ -321,7 +326,7 @@ update_desktop_file_entry (BusActivation *activation,
if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY))
{
dbus_move_error (&tmp_error, error);
goto failed;
goto out;
}
else
{
@ -344,7 +349,7 @@ update_desktop_file_entry (BusActivation *activation,
if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY))
{
dbus_move_error (&tmp_error, error);
goto failed;
goto out;
}
else
{
@ -360,8 +365,6 @@ update_desktop_file_entry (BusActivation *activation,
entry = _dbus_hash_table_lookup_string (s_dir->entries,
_dbus_string_get_const_data (filename));
exec = strdup (_dbus_replace_install_prefix (exec_tmp));
if (entry == NULL) /* New file */
{
/* FIXME we need a better-defined algorithm for which service file to
@ -371,14 +374,14 @@ update_desktop_file_entry (BusActivation *activation,
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Service %s already exists in activation entry list\n", name);
goto failed;
goto out;
}
entry = dbus_new0 (BusActivationEntry, 1);
if (entry == NULL)
{
BUS_SET_OOM (error);
goto failed;
goto out;
}
entry->name = name;
@ -387,18 +390,24 @@ update_desktop_file_entry (BusActivation *activation,
entry->systemd_service = systemd_service;
entry->refcount = 1;
/* ownership has been transferred to entry, do not free separately */
name = NULL;
exec = NULL;
user = NULL;
systemd_service = NULL;
entry->s_dir = s_dir;
entry->filename = _dbus_strdup (_dbus_string_get_const_data (filename));
if (!entry->filename)
{
BUS_SET_OOM (error);
goto failed;
goto out;
}
if (!_dbus_hash_table_insert_string (activation->entries, entry->name, bus_activation_entry_ref (entry)))
{
BUS_SET_OOM (error);
goto failed;
goto out;
}
if (!_dbus_hash_table_insert_string (s_dir->entries, entry->filename, bus_activation_entry_ref (entry)))
@ -406,7 +415,7 @@ update_desktop_file_entry (BusActivation *activation,
/* Revert the insertion in the entries table */
_dbus_hash_table_remove_string (activation->entries, entry->name);
BUS_SET_OOM (error);
goto failed;
goto out;
}
_dbus_verbose ("Added \"%s\" to list of services\n", entry->name);
@ -420,17 +429,26 @@ update_desktop_file_entry (BusActivation *activation,
{
_dbus_verbose ("The new service name \"%s\" of service file \"%s\" already in cache, ignoring\n",
name, _dbus_string_get_const_data (&file_path));
goto failed;
goto out;
}
/* ownership has been transferred to entry, do not free separately */
dbus_free (entry->name);
entry->name = name;
name = NULL;
dbus_free (entry->exec);
entry->exec = exec;
exec = NULL;
dbus_free (entry->user);
entry->user = user;
user = NULL;
dbus_free (entry->systemd_service);
entry->systemd_service = systemd_service;
entry->name = name;
entry->exec = exec;
entry->user = user;
systemd_service = NULL;
if (!_dbus_hash_table_insert_string (activation->entries,
entry->name, bus_activation_entry_ref(entry)))
{
@ -445,15 +463,12 @@ update_desktop_file_entry (BusActivation *activation,
}
entry->mtime = stat_buf.mtime;
retval = TRUE;
_dbus_string_free (&file_path);
bus_activation_entry_unref (entry);
return TRUE;
failed:
out:
/* if these have been transferred into entry, the variables will be NULL */
dbus_free (name);
dbus_free (exec_tmp);
dbus_free (exec);
dbus_free (user);
dbus_free (systemd_service);
_dbus_string_free (&file_path);

View file

@ -30,6 +30,7 @@
#include "dbus-auth.h"
#include "dbus-address.h"
#include "dbus-credentials.h"
#include "dbus-mainloop.h"
#include "dbus-message-private.h"
#include "dbus-marshal-header.h"
#ifdef DBUS_BUILD_TESTS
@ -741,17 +742,6 @@ _dbus_transport_get_is_authenticated (DBusTransport *transport)
_dbus_connection_unref_unlocked (transport->connection);
return FALSE;
}
if (transport->expected_guid == NULL)
{
transport->expected_guid = _dbus_strdup (server_guid);
if (transport->expected_guid == NULL)
{
_dbus_verbose ("No memory to complete auth\n");
return FALSE;
}
}
}
/* If we're the server, see if we want to allow this identity to proceed.
@ -853,6 +843,8 @@ _dbus_transport_get_server_id (DBusTransport *transport)
{
if (transport->is_server)
return NULL;
else if (transport->authenticated)
return _dbus_auth_get_guid_from_server (transport->auth);
else
return transport->expected_guid;
}