From 68db67c4eb9b158e5b8af9a2ae0cab9f04f1d594 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 26 Aug 2021 23:49:14 +0200 Subject: [PATCH] [MIRROR] [s] Patch a server crashing exploit (#7794) * [s] Patch a server crashing exploit (#61057) if you create a bunch of signallers then spam the send signal button you can grind the server to a halt at low numbers and crash it at high numbers of signallers This is an imperfect fix as a proper fix would refactor signal datums to use a subsystem but I dont feel like rewriting all of signal code thank you very much Co-authored-by: Zephyr <12817816+ZephyrTFA@ users.noreply.github.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> * [s] Patch a server crashing exploit Co-authored-by: TiviPlus <57223640+TiviPlus@users.noreply.github.com> Co-authored-by: Zephyr <12817816+ZephyrTFA@ users.noreply.github.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> --- code/__DEFINES/cooldowns.dm | 4 +++- code/game/communications.dm | 1 + code/modules/assembly/signaler.dm | 4 ++++ code/modules/wiremod/components/action/radio.dm | 5 ++++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/code/__DEFINES/cooldowns.dm b/code/__DEFINES/cooldowns.dm index fe72b872053..6bca58aac18 100644 --- a/code/__DEFINES/cooldowns.dm +++ b/code/__DEFINES/cooldowns.dm @@ -42,8 +42,10 @@ //clown car cooldowns #define COOLDOWN_CLOWNCAR_RANDOMNESS "clown_car_randomness" -//circuit cooldowns +// item cooldowns +#define COOLDOWN_SIGNALLER_SEND "cooldown_signaller_send" +//circuit cooldowns #define COOLDOWN_CIRCUIT_SOUNDEMITTER "circuit_soundemitter" #define COOLDOWN_CIRCUIT_SPEECH "circuit_speech" #define COOLDOWN_CIRCUIT_PATHFIND_SAME "circuit_pathfind_same" diff --git a/code/game/communications.dm b/code/game/communications.dm index 3c52c5b2eaa..99cfcc39663 100644 --- a/code/game/communications.dm +++ b/code/game/communications.dm @@ -180,6 +180,7 @@ GLOBAL_LIST_INIT(reverseradiochannels, list( if(start_point.z != end_point.z || (range > 0 && get_dist(start_point, end_point) > range)) continue device.receive_signal(signal) + CHECK_TICK /datum/radio_frequency/proc/add_listener(obj/device, filter as text|null) if (!filter) diff --git a/code/modules/assembly/signaler.dm b/code/modules/assembly/signaler.dm index d6fa2c82dbe..157be028163 100644 --- a/code/modules/assembly/signaler.dm +++ b/code/modules/assembly/signaler.dm @@ -91,6 +91,10 @@ switch(action) if("signal") + if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_SIGNALLER_SEND)) + to_chat(usr, span_warning("[src] is still recharging...")) + return + TIMER_COOLDOWN_START(src, COOLDOWN_SIGNALLER_SEND, 1 SECONDS) INVOKE_ASYNC(src, .proc/signal) . = TRUE if("freq") diff --git a/code/modules/wiremod/components/action/radio.dm b/code/modules/wiremod/components/action/radio.dm index 540b79f7cf5..109a7428f44 100644 --- a/code/modules/wiremod/components/action/radio.dm +++ b/code/modules/wiremod/components/action/radio.dm @@ -34,7 +34,7 @@ . = ..() freq = add_input_port("Frequency", PORT_TYPE_NUMBER, default = FREQ_SIGNALER) code = add_input_port("Code", PORT_TYPE_NUMBER, default = DEFAULT_SIGNALER_CODE) - TRIGGER_CIRCUIT_COMPONENT(src, null) + INVOKE_ASYNC(src, .proc/apply_signal_component) // These are cleaned up on the parent trigger_input = add_input_port("Send", PORT_TYPE_SIGNAL) trigger_output = add_output_port("Received", PORT_TYPE_SIGNAL) @@ -43,6 +43,9 @@ SSradio.remove_object(src, current_freq) return ..() +/obj/item/circuit_component/radio/proc/apply_signal_component() + TRIGGER_CIRCUIT_COMPONENT(src, null) + /obj/item/circuit_component/radio/input_received(datum/port/input/port) . = ..() freq.set_value(sanitize_frequency(freq.value, TRUE))