From 320ec9354482fd574381202a801efa3aaa09e003 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Mon, 23 Dec 2024 07:08:44 +1300 Subject: [PATCH] Limit chatcommand parameter length in command blocks (#695) --- mesecons_commandblock/init.lua | 6 ++++++ settingtypes.txt | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/mesecons_commandblock/init.lua b/mesecons_commandblock/init.lua index fd1c7d2..853f16c 100644 --- a/mesecons_commandblock/init.lua +++ b/mesecons_commandblock/init.lua @@ -1,4 +1,5 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local param_maxlen = mesecon.setting("commandblock_param_maxlen", 10000) minetest.register_chatcommand("say", { params = "", @@ -156,6 +157,11 @@ local function commandblock_action_on(pos, node) minetest.chat_send_player(owner, "The command "..cmd.." does not exist") return end + if #param > param_maxlen then + minetest.chat_send_player(owner, "Command parameters are limited to max. " .. + param_maxlen .. " bytes.") + return + end local has_privs, missing_privs = minetest.check_player_privs(owner, cmddef.privs) if not has_privs then minetest.chat_send_player(owner, "You don't have permission " diff --git a/settingtypes.txt b/settingtypes.txt index 688baf2..455c90a 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -11,6 +11,11 @@ mesecon.cooldown_granularity (Cooldown step length) float 0.5 0.0 1.0 mesecon.blinky_plant_interval (Plant blinking interval) int 3 1 5 +[mesecons_commandblock] + +mesecon.commandblock_param_maxlen (Maximum command parameter length) int 10000 100 1000000 + + [mesecons_detector] mesecon.detector_radius (Player detector scanning radius) int 6 3 16