From 2e51ae04c8f2b75d5529171474959d000318f744 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 22 Jun 2017 22:49:06 +0100 Subject: [PATCH] bus/containers: Enforce max_containers limit Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354 --- bus/containers.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bus/containers.c b/bus/containers.c index f3c97c66..7bff2ce3 100644 --- a/bus/containers.c +++ b/bus/containers.c @@ -796,6 +796,24 @@ bus_containers_handle_add_server (DBusConnection *connection, goto oom; } + limit = bus_context_get_max_containers (context); + + if (_dbus_hash_table_get_n_entries (containers->instances_by_path) >= limit) + { + DBusError local_error = DBUS_ERROR_INIT; + + dbus_set_error (&local_error, DBUS_ERROR_LIMITS_EXCEEDED, + "Connection \"%s\" (%s) is not allowed to create more " + "container servers (max_containers=%d)", + bus_connection_get_name (connection), + bus_connection_get_loginfo (connection), + limit); + bus_context_log_literal (context, DBUS_SYSTEM_LOG_WARNING, + local_error.message); + dbus_move_error (&local_error, error); + goto fail; + } + if (!_dbus_hash_table_insert_string (containers->instances_by_path, instance->path, instance)) goto oom; -- 2.13.3