"path",
"searchpath",
};
+#if USE_LUAJIT
static const char *jit_whitelist[] = {
"arch",
"flush",
"version",
"version_num",
};
-
+#endif
m_secure = true;
lua_State *L = getStack();
"table",
"math",
};
- static const char *io_whitelist[] = {
- "close",
- "flush",
- "read",
- "type",
- "write",
- };
static const char *os_whitelist[] = {
"clock",
"date",
"getinfo",
};
+#if USE_LUAJIT
static const char *jit_whitelist[] = {
"arch",
"flush",
"version",
"version_num",
};
+#endif
m_secure = true;
lua_pop(L, 1);
- // Copy safe IO functions
- lua_getfield(L, old_globals, "io");
- lua_newtable(L);
- copy_safe(L, io_whitelist, sizeof(io_whitelist));
-
- // And replace unsafe ones
- SECURE_API(io, open);
- SECURE_API(io, input);
- SECURE_API(io, output);
- SECURE_API(io, lines);
-
- lua_setglobal(L, "io");
- lua_pop(L, 1); // Pop old IO
-
// Copy safe OS functions
lua_getfield(L, old_globals, "os");
lua_setglobal(L, "debug");
lua_pop(L, 1); // Pop old debug
- // Remove all of package
- lua_newtable(L);
- lua_setglobal(L, "package");
-
#if USE_LUAJIT
// Copy safe jit functions, if they exist
lua_getfield(L, -1, "jit");
// Read the file
int ret = std::fseek(fp, 0, SEEK_END);
- CHECK_FILE_ERR(ret, fp);
+ if (ret) {
+ lua_pushfstring(L, "%s: %s", path, strerror(errno));
+ std::fclose(fp);
+ if (path) {
+ delete [] chunk_name;
+ }
+ return false;
+ }
size_t size = std::ftell(fp) - start;
char *code = new char[size];