daemon: Plug leak of AddMatch rules for RegisterClient

I noticed this when I set up a `while true; do rpm-ostree status; done` loop
to test: https://github.com/projectatomic/rpm-ostree/pull/814
This is a local, authenticated DoS of sorts, but there are honestly a lot of
those, IMO not worth a CVE.

Closes: https://github.com/projectatomic/rpm-ostree/issues/815

Closes: #816
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-06-02 12:40:19 -04:00 committed by Atomic Bot
parent e5294829b8
commit 02f1fa678e

View File

@ -363,6 +363,7 @@ rpmostreed_daemon_add_client (RpmostreedDaemon *self,
{
if (g_hash_table_lookup (self->bus_clients, client))
return;
guint subid =
g_dbus_connection_signal_subscribe (self->connection,
"org.freedesktop.DBus",
"org.freedesktop.DBus",
@ -374,7 +375,7 @@ rpmostreed_daemon_add_client (RpmostreedDaemon *self,
g_object_ref (self),
g_object_unref);
g_hash_table_add (self->bus_clients, g_strdup (client));
g_hash_table_insert (self->bus_clients, g_strdup (client), GUINT_TO_POINTER (subid));
sd_journal_print (LOG_INFO, "Client %s added; new total=%u", client, g_hash_table_size (self->bus_clients));
render_systemd_status (self);
}
@ -383,8 +384,10 @@ void
rpmostreed_daemon_remove_client (RpmostreedDaemon *self,
const char *client)
{
if (!g_hash_table_lookup (self->bus_clients, client))
gpointer origkey, subid_p;
if (!g_hash_table_lookup_extended (self->bus_clients, client, &origkey, &subid_p))
return;
g_dbus_connection_signal_unsubscribe (self->connection, GPOINTER_TO_UINT (subid_p));
g_hash_table_remove (self->bus_clients, client);
sd_journal_print (LOG_INFO, "Client %s vanished; remaining=%u", client, g_hash_table_size (self->bus_clients));
render_systemd_status (self);