[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Preventing DOS when executing Lua code ...
- From: Mark Hamburg <mhamburg@...>
- Date: Wed, 05 Jul 2006 09:26:16 -0700
on 7/3/06 12:14 AM, Andreas Stenius at kaos@explosive.se wrote:
> One way could be to call lua_error instead of longjmp in your hook, but
> then you have to remove pcall from the user environment, or he'll be
> able to catch it.
Or redefine pcall so that it looks for a particular error and always
propagates it. In Lua, I think the following is correct (untested):
local kMagicError = { }
local old_pcall = pcall
function new_pcall
function new_pcall_finish( success, ... )
if not success then
local message = ...
if message == kMagicError then
error( kMagicError )
end
end
return success, ...
end
pcall = function( ... )
return new_pcall_finish( old_pcall( ... ) )
end
function throwMagicError()
error( kMagicError )
end
You would want to access throwMagicError from your hook proc.
Mark