summaryrefslogtreecommitdiff
path: root/dbus
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-01-26 18:55:00 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-01-26 18:55:00 +0000
commit799cef5f9e5ef5049008fd4a3816d38f15fa6cb9 (patch)
tree32bb2ea725488d80466b162ed9552340332306e5 /dbus
parent96a6d143765ae571e29155346cd7ae954e77d89e (diff)
_dbus_server_new_for_tcp_socket: fix error handling
This is one of the patches from Maemo's dbus package. It seems to do all of: * fix some documentation * remove unreached code to delete/free the nonce file from _dbus_server_new_for_socket - doing that on failure violates least-astonishment anyway * in _dbus_server_new_for_tcp_socket, never fail without setting @error * if we fail after creating the nonce file, delete it * if we fail after allocating the nonce file struct, free it Origin: vendor, Maemo Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33128 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-server-socket.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c
index 758742dd..e8a24e48 100644
--- a/dbus/dbus-server-socket.c
+++ b/dbus/dbus-server-socket.c
@@ -273,7 +273,7 @@ static const DBusServerVTable socket_vtable = {
* @param fds list of file descriptors.
* @param n_fds number of file descriptors
* @param address the server's address
- * @param use_nonce whether to create and use a nonce for authentication
+ * @param noncefile to be used for authentication (NULL if not needed)
* @returns the new server, or #NULL if no memory.
*
*/
@@ -346,12 +346,6 @@ _dbus_server_new_for_socket (int *fds,
return (DBusServer*) socket_server;
- failed_3:
- if (socket_server->noncefile)
- {
- _dbus_noncefile_delete (socket_server->noncefile, NULL);
- dbus_free (socket_server->noncefile );
- }
failed_2:
for (i = 0 ; i < n_fds ; i++)
{
@@ -464,16 +458,18 @@ _dbus_server_new_for_tcp_socket (const char *host,
noncefile = dbus_new0 (DBusNonceFile, 1);
if (noncefile == NULL)
{
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto failed_2;
}
- if (!_dbus_noncefile_create (noncefile, NULL))
- goto failed_2;
+ if (!_dbus_noncefile_create (noncefile, error))
+ goto failed_3;
if (!_dbus_string_append (&address, ",noncefile=") ||
!_dbus_address_append_escaped (&address, _dbus_noncefile_get_path (noncefile)))
{
- goto failed_2;
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ goto failed_4;
}
}
@@ -482,7 +478,7 @@ _dbus_server_new_for_tcp_socket (const char *host,
if (server == NULL)
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- goto failed_2;
+ goto failed_4;
}
_dbus_string_free (&port_str);
@@ -491,6 +487,12 @@ _dbus_server_new_for_tcp_socket (const char *host,
return server;
+ failed_4:
+ _dbus_noncefile_delete (noncefile, NULL);
+
+ failed_3:
+ dbus_free (noncefile);
+
failed_2:
for (i = 0 ; i < nlisten_fds ; i++)
_dbus_close_socket (listen_fds[i], NULL);