[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Restricted compile/execute mode
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sun, 28 Oct 2007 09:34:50 -0200
> But this way you would still accept (weird) things like:
>
> (function () _G.mynewfunction = function () ... end end)()
Right. You need to use sandbox techniques or simply disable the "function"
keyword with, say, a token filter as the one below:
/*
* proxy.c
* lexer proxy for Lua parser -- disables "function"
* This code is hereby placed in the public domain.
* Add <<#include "proxy.c">> just before the definition of luaX_next in llex.c
*/
static int nexttoken(LexState *ls, SemInfo *seminfo)
{
int t=llex(ls,seminfo);
if (t==TK_FUNCTION) t=TK_NIL;
return t;
}
#define llex nexttoken