From 657c2a68b061c9fe86925e222664dec45e524cf2 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Tue, 30 May 2006 15:34:10 +0000 Subject: * dbus/dbus-sysdeps.c: Make tcp socket connection error somewhat more clear: "Failed to connect to socket : " instead of "Failed to connect to socket : :" * dbus/dbus-transport-unix.c: Fix crash when no host option is given for a tcp transport. --- ChangeLog | 10 ++++++++++ dbus/dbus-sysdeps.c | 4 ++-- dbus/dbus-transport-unix.c | 25 ++++++++++++++++--------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index d49cdc8..4c72e18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-05-30 Sjoerd Simons + + * dbus/dbus-sysdeps.c: Make tcp socket connection error somewhat more + clear: + "Failed to connect to socket : " instead of + "Failed to connect to socket : :" + + * dbus/dbus-transport-unix.c: Fix crash when no host option is given + for a tcp transport. + 2006-05-29 Thiago Macieira * qt/*: Update the QtDBus bindings up to revision 546310 in diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index e8bd9b7..e935dfa 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -678,8 +678,8 @@ _dbus_connect_tcp_socket (const char *host, { dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to connect to socket %s: %s:%d", - host, _dbus_strerror (errno), port); + "Failed to connect to socket %s:%d %s", + host, port, _dbus_strerror (errno)); close (fd); fd = -1; diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c index f88a45b..39216ca 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; } /** @} */ -- cgit v1.2.3