From: Auke Kok Date: Tue, 5 Feb 2019 05:28:00 +0000 (-0800) Subject: Limit sign length to 512 (~6 lines of 80 char or so). X-Git-Tag: 5.0.0~4 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6b2887e3bfc0e8db1d8149bc95039af43922ffc6;p=oweals%2Fminetest_game.git Limit sign length to 512 (~6 lines of 80 char or so). Players can enter unlimited text into the field, causing lag and potentially locking up clients. I have not found any negative effects server side, other than the large storage needed to store the long text. --- diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index ecd8f776..c067eac3 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -2575,12 +2575,19 @@ local function register_sign(material, desc, def) minetest.record_protection_violation(pos, player_name) return end - local meta = minetest.get_meta(pos) - if not fields.text then return end + local text = fields.text + if not text then + return + end + if string.len(text) > 512 then + minetest.chat_send_player(player_name, "Text too long") + return + end minetest.log("action", (player_name or "") .. " wrote \"" .. - fields.text .. "\" to sign at " .. minetest.pos_to_string(pos)) - meta:set_string("text", fields.text) - meta:set_string("infotext", '"' .. fields.text .. '"') + text .. "\" to sign at " .. minetest.pos_to_string(pos)) + local meta = minetest.get_meta(pos) + meta:set_string("text", text) + meta:set_string("infotext", '"' .. text .. '"') end, }) end