Skip to content

Commit

Permalink
Limit chatcommand parameter length in command blocks (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
luk3yx authored Dec 22, 2024
1 parent 8051129 commit 320ec93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mesecons_commandblock/init.lua
Original file line number Diff line number Diff line change
@@ -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 = "<text>",
Expand Down Expand Up @@ -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 "
Expand Down
5 changes: 5 additions & 0 deletions settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 320ec93

Please sign in to comment.