diff options
author | rubidium42 <rubidium@openttd.org> | 2021-06-04 18:59:13 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-06-10 22:03:23 +0200 |
commit | 2924ac48c5013acf18b7577de4f610612d88dd6c (patch) | |
tree | 3436720b94027ccfd1f4d5f6662b944e0591f8ea | |
parent | bb8fd007605c17c4f96fdda75e3d2780b8944faf (diff) | |
download | openttd-2924ac48c5013acf18b7577de4f610612d88dd6c.tar.xz |
Fix: [Script] Ensure the saved script strings are properly validated and terminated when being read from the savegame
-rw-r--r-- | src/script/script_instance.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index 24dbb9c39..7c2fa43d6 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -569,8 +569,9 @@ bool ScriptInstance::IsPaused() case SQSL_STRING: { SlObject(nullptr, _script_byte); - static char buf[256]; + static char buf[std::numeric_limits<decltype(_script_sl_byte)>::max()]; SlArray(buf, _script_sl_byte, SLE_CHAR); + StrMakeValidInPlace(buf, buf + _script_sl_byte); if (vm != nullptr) sq_pushstring(vm, buf, -1); return true; } |