From: Simon McVittie Date: Tue, 1 Feb 2011 12:27:39 +0000 (+0000) Subject: DBusTransport: don't copy DBusAuth's GUID to expected_guid X-Git-Tag: dbus-1.4.4~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2acfe412b6c63a4a08deb52e9395562ca47d1101;p=thirdparty%2Fdbus.git DBusTransport: don't copy DBusAuth's GUID to expected_guid There was previously a leak in _dbus_transport_get_is_authenticated, if we hit OOM when copying the server's actual GUID. This would fail the "SHA1 connection test" if _dbus_iterate was modified to allocate and free one extra pointer per iteration. Rather than adding OOM handling everywhere, if we avoid strdup'ing the GUID, and just re-fetch the const string from the DBusAuth object on demand instead, we go back to a situation where _dbus_transport_get_is_authenticated can't fail. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33126 --- diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index a078f7c6a..ba6bd4b4b 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -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; }