From 5056e963bab9683656e07e527b339f370383fa77 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Fri, 12 Mar 2021 09:26:03 +0100 Subject: [PATCH] Fix #8851: don't allow infinite "exec" depth in script, but limit to 10 deep This means if you execute a script from a script from a script, .. for more than 10 times, it bails out now. This should be sufficient for even the most complex scripts. --- src/console_cmds.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index f66cfa6b67..f50644cf5b 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -960,6 +960,11 @@ DEF_CONSOLE_CMD(ConExec) return true; } + if (_script_current_depth == 11) { + IConsoleError("Maximum 'exec' depth reached; script A is calling script B is calling script C ... more than 10 times."); + return true; + } + _script_current_depth++; uint script_depth = _script_current_depth;