From 53cfed7c8b8a4274ca9bbcfe4bc80a52b1d13402 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 3 Nov 2019 12:40:57 +0100 Subject: [PATCH] LibCore: Put a limit on how many unsent messages an IPC server queues This patch adds a limit of 200 unsent messages per client. If a client does not handle its incoming messages and we manage to queue up 200 messages for it, we'll now disconnect that client. :^) --- Libraries/LibCore/CoreIPCServer.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Libraries/LibCore/CoreIPCServer.h b/Libraries/LibCore/CoreIPCServer.h index c07885c4bc2..49a75c8c58d 100644 --- a/Libraries/LibCore/CoreIPCServer.h +++ b/Libraries/LibCore/CoreIPCServer.h @@ -95,6 +95,12 @@ namespace Server { #endif if (try_send_message(message, extra_data)) return; + if (m_queue.size() >= max_queued_messages) { + dbg() << "Connection::post_message: Client has too many queued messages already, disconnecting it."; + shutdown(); + return; + } + QueuedMessage queued_message { message, extra_data }; if (!extra_data.is_empty()) queued_message.message.extra_size = extra_data.size(); @@ -232,6 +238,8 @@ namespace Server { ServerMessage message; ByteBuffer extra_data; }; + + static const int max_queued_messages = 200; Queue m_queue; int m_client_id { -1 };