mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-28 23:13:23 +01:00
fix(scripting): close the small holes in the script screen sandbox
- Lua: once the instruction budget of a call is spent, the count hook runs at every instruction and raises again, so pcall, nested pcall and coroutine.resume can't swallow the limit; xpcall is rebuilt on pcall so its handler runs after the error left f, while the hook works - Lua: the metatables of eu07.image/font/sprite are locked (__metatable = false); __gc destroys only an object of its own type, once - Lua: read_png checks the size with stbi_info before decoding - Lua: string.rep makes no string over 1 MiB - Lua and WASM: at most 64 commands per call, names up to 64 bytes, 32 log lines per call cut at 1024 bytes; the drops are logged once - fonts: a glyph wider than 4096 is skipped; more than 4096 glyphs, 8192 columns or an image side over 4096 refuse the font; cut_glyph reads only the columns inside the image - the script path from the .mmd (cab screens, destination signs, make: textures) must stay inside the game folder; the files a screen reads, its script and its module must be regular files of 16 MiB at most Tests for each in test_script_screen_host.cpp, test_script_screen_drawing.cpp and test_script_screens.cpp; the test stubs can capture the log.
This commit is contained in:
@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
@@ -72,4 +73,9 @@ class frame_schedule
|
||||
// drive or a leading separator
|
||||
bool is_safe_relative_path(std::string_view Path);
|
||||
|
||||
// the path the game opens the script of a screen by: a name without a folder is in the vehicle's folder (Folder), a
|
||||
// path is from the game's folder. nothing for a path that leads outside the game's folder (as for the files a screen
|
||||
// reads: absolute, with a drive, or with ".."), since the script's folder is the one the screen then reads files from
|
||||
std::optional<std::string> screen_script_path(std::string const &Folder, std::string const &Script);
|
||||
|
||||
} // namespace script_screens
|
||||
|
||||
Reference in New Issue
Block a user