lua-api

Execution time limit for a Lua script called from the C API

luaL_loadfile(mState, path.c_str()); lua_pcall(mState, 0, 0, 0); Is there a way to put an execution time limit (say 10-20 seconds) for those two C++ statements, that load and then execute a lua file? Since the Lua file is untrusted I don't want a malicious user to hang the program indefinitely with an infinite loop in the Lua code. T...

Calling lua functions from .lua's using handles?

Hey there, I'm working on a small project trying to integrate lua with c++. My problem however is as follows: I have multiple lua scripts, lets call them s1.lua s2.lua and s3.lua. Each of these has the following functions: setVars() and executeResults(). Now I am able to to call a lua file through LuaL_dofile and immediately after use...

How to execute an untrusted Lua file in its own environment from the C API

I want to execute an untrusted .lua file in its own environment by calling lua_setfenv() so that it cannot affect any of my code. The documentation for that function though only explains how to call a function, not how to execute a file. Currently to run the file I use: int error = luaL_loadfile(mState, path.c_str()) || lua_pcall(mSta...