mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 18:46:43 +00:00
Cleanup state stack during sandboxing process
This commit is contained in:
parent
b86d330532
commit
40295112fe
1 changed files with 7 additions and 4 deletions
|
@ -37,6 +37,8 @@ internal class Sandbox
|
||||||
L.OpenOS();
|
L.OpenOS();
|
||||||
|
|
||||||
L.OpenPackage();
|
L.OpenPackage();
|
||||||
|
|
||||||
|
L.SetTop(0);
|
||||||
}
|
}
|
||||||
internal static void Patch(Lua L)
|
internal static void Patch(Lua L)
|
||||||
{
|
{
|
||||||
|
@ -70,10 +72,11 @@ internal class Sandbox
|
||||||
L.PushString("config");
|
L.PushString("config");
|
||||||
L.PushString(packageConfig);
|
L.PushString(packageConfig);
|
||||||
L.SetTable(-4);
|
L.SetTable(-4);
|
||||||
|
L.Pop(1);
|
||||||
|
|
||||||
// delete 3 and 4 searchers
|
// delete 3 and 4 searchers
|
||||||
L.PushString("searchers");
|
L.PushString("searchers");
|
||||||
L.GetTable(-3);
|
L.GetTable(-2);
|
||||||
|
|
||||||
L.PushNil();
|
L.PushNil();
|
||||||
L.SetInteger(-2, 3);
|
L.SetInteger(-2, 3);
|
||||||
|
@ -84,7 +87,7 @@ internal class Sandbox
|
||||||
L.PushCFunction(L_Searcher);
|
L.PushCFunction(L_Searcher);
|
||||||
L.SetInteger(-2, 2);
|
L.SetInteger(-2, 2);
|
||||||
|
|
||||||
L.Pop(L.GetTop());
|
L.Pop(2);
|
||||||
|
|
||||||
// Replace loadfile with sandboxed one
|
// Replace loadfile with sandboxed one
|
||||||
L.PushCFunction(L_Loadfile);
|
L.PushCFunction(L_Loadfile);
|
||||||
|
@ -94,8 +97,6 @@ internal class Sandbox
|
||||||
L.PushCFunction(L_Dofile);
|
L.PushCFunction(L_Dofile);
|
||||||
L.SetGlobal("dofile");
|
L.SetGlobal("dofile");
|
||||||
|
|
||||||
L.Pop(L.GetTop());
|
|
||||||
|
|
||||||
// yeet dangerous os functions
|
// yeet dangerous os functions
|
||||||
L.GetGlobal("os");
|
L.GetGlobal("os");
|
||||||
|
|
||||||
|
@ -118,6 +119,8 @@ internal class Sandbox
|
||||||
L.PushString("getenv");
|
L.PushString("getenv");
|
||||||
L.PushNil();
|
L.PushNil();
|
||||||
L.SetTable(-3);
|
L.SetTable(-3);
|
||||||
|
|
||||||
|
L.Pop(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static int L_Searcher(IntPtr state)
|
internal static int L_Searcher(IntPtr state)
|
||||||
|
|
Loading…
Reference in a new issue