Skip to content

Commit 6983db6

Browse files
committedMar 23, 2013
Add math library to luacontroller, and make sure to copy stuff so code can't get out of the sandbox.
1 parent 1ff437b commit 6983db6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎mesecons_luacontroller/init.lua

+10-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ local create_environment = function(pos, mem, event)
195195
mem = mem,
196196
tostring = tostring,
197197
tonumber = tonumber,
198-
string = string,
198+
string = tablecopy(string),
199+
math = tablecopy(math),
199200
event = event}
200201
end
201202

@@ -222,6 +223,14 @@ local do_overheat = function (pos, meta)
222223
end
223224
end
224225

226+
local tablecopy = function(t)
227+
local tnew = {}
228+
for key, value in pairs(t) do
229+
tnew[key] = value
230+
end
231+
return tnew
232+
end
233+
225234
local load_memory = function(meta)
226235
return minetest.deserialize(meta:get_string("lc_memory")) or {}
227236
end

0 commit comments

Comments
 (0)
Please sign in to comment.