diff options
author | Sjoerd Simons <sjoerd@luon.net> | 2006-05-30 15:34:10 +0000 |
---|---|---|
committer | Sjoerd Simons <sjoerd@luon.net> | 2006-05-30 15:34:10 +0000 |
commit | 435c7af9b605c3ffc8641142b6d7add18bf7080b (patch) | |
tree | 2648f711564f9ebaca3c31df7c7b93a5c8c45b04 /dbus/dbus-transport-unix.c | |
parent | 26ab02e91671548e2b55a16bb953b3d9e0a82497 (diff) |
* dbus/dbus-sysdeps.c: Make tcp socket connection error somewhat more
clear:
"Failed to connect to socket <host>:<port> <error>" instead of
"Failed to connect to socket <host>: <error>:<port>"
* dbus/dbus-transport-unix.c: Fix crash when no host option is given
for a tcp transport.
Diffstat (limited to 'dbus/dbus-transport-unix.c')
-rw-r--r-- | dbus/dbus-transport-unix.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c index f88a45bc..39216cab 100644 --- a/dbus/dbus-transport-unix.c +++ b/dbus/dbus-transport-unix.c @@ -1272,16 +1272,18 @@ _dbus_transport_new_for_tcp_socket (const char *host, return NULL; } - if (!_dbus_string_append (&address, "tcp:host=") || - !_dbus_string_append (&address, host) || - !_dbus_string_append (&address, ",port=") || + if (!_dbus_string_append (&address, "tcp:")) + goto error; + + if (host != NULL && + (!_dbus_string_append (&address, "host=") || + !_dbus_string_append (&address, host))) + goto error; + + if (!_dbus_string_append (&address, ",port=") || !_dbus_string_append_int (&address, port)) - { - _dbus_string_free (&address); - dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); - return NULL; - } - + goto error; + fd = _dbus_connect_tcp_socket (host, port, error); if (fd < 0) { @@ -1307,6 +1309,11 @@ _dbus_transport_new_for_tcp_socket (const char *host, _dbus_string_free (&address); return transport; + +error: + _dbus_string_free (&address); + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + return NULL; } /** @} */ |