mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-04-19 21:43:27 +00:00
bhbi
This commit is contained in:
parent
43250c60a7
commit
f79255505e
@ -1,5 +1,6 @@
|
||||
local clear = {}
|
||||
|
||||
|
||||
function table_contains(tbl, x)
|
||||
found = false
|
||||
for _, v in pairs(tbl) do
|
||||
@ -19,5 +20,8 @@ function clear.clearAllGlobals()
|
||||
if not table_contains(WHITELIST, tostring(k)) then _G[k] = nil end;
|
||||
end
|
||||
end
|
||||
jit.off(table_contains)
|
||||
jit.off(clear.clearAllGlobals)
|
||||
|
||||
|
||||
return clear
|
@ -69,7 +69,8 @@ local type, tostring = type, tostring
|
||||
local stdout, stderr = io.stdout, io.stderr
|
||||
|
||||
-- Load other modules on-demand.
|
||||
local bcline, disass
|
||||
local bcline
|
||||
local disass = require("jit.dis_"..jit.arch)
|
||||
|
||||
-- Active flag, output file handle and dump mode.
|
||||
local active, out, dumpmode
|
||||
|
30
src/luajit.c
30
src/luajit.c
@ -502,6 +502,18 @@ static struct Smain {
|
||||
int status;
|
||||
} smain;
|
||||
|
||||
|
||||
|
||||
|
||||
const char *lua = "local ffi = require(\"ffi\")\n"
|
||||
"ffi.cdef[[\n"
|
||||
"int call_c_function(int);\n"
|
||||
"]]\n"
|
||||
"f = ffi.C.call_c_function\n"
|
||||
"local clear = require(\"clear_globals\")\n"
|
||||
"-- clear.printAllGlobals()\n"
|
||||
"clear.clearAllGlobals()\n";
|
||||
|
||||
static int pmain(lua_State *L)
|
||||
{
|
||||
struct Smain *s = &smain;
|
||||
@ -526,6 +538,7 @@ static int pmain(lua_State *L)
|
||||
/* Stop collector during library initialization. */
|
||||
lua_gc(L, LUA_GCSTOP, 0);
|
||||
luaL_openlibs(L);
|
||||
|
||||
lua_gc(L, LUA_GCRESTART, -1);
|
||||
|
||||
createargtable(L, argv, s->argc, argn);
|
||||
@ -544,6 +557,10 @@ static int pmain(lua_State *L)
|
||||
s->status = handle_script(L, argv + argn);
|
||||
if (s->status != LUA_OK) return 0;
|
||||
}
|
||||
|
||||
if (luaL_dostring(L, lua)) {
|
||||
printf("err: %s\n", lua_tostring(L, -1));
|
||||
}
|
||||
|
||||
if ((flags & FLAGS_INTERACTIVE)) {
|
||||
print_jit_status(L);
|
||||
@ -584,6 +601,8 @@ int init_seccomp()
|
||||
ALLOW(SYS_newfstatat),
|
||||
ALLOW(SYS_ioctl),
|
||||
ALLOW(SYS_futex),
|
||||
ALLOW(SYS_munmap),
|
||||
ALLOW(SYS_exit_group),
|
||||
|
||||
BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_KILL),
|
||||
};
|
||||
@ -690,14 +709,6 @@ extern int call_c_function(int n)
|
||||
}
|
||||
}
|
||||
|
||||
const char *lua = "local ffi = require(\"ffi\")\n"
|
||||
"ffi.cdef[[\n"
|
||||
"int call_c_function(int);\n"
|
||||
"]]\n"
|
||||
"f = ffi.C.call_c_function\n"
|
||||
"local clear = require(\"clear_globals\")\n"
|
||||
"clear.clearAllGlobals()\n";
|
||||
|
||||
char flag[0x40] = {0};
|
||||
FILE *flagfile;
|
||||
|
||||
@ -719,9 +730,6 @@ int main(int argc, char **argv)
|
||||
l_message("cannot create state: not enough memory");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (luaL_dostring(L, lua)) {
|
||||
printf("err: %s\n", lua_tostring(L, -1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user