From 28d0e6dfc0bfbec0ed247bda1825908eefbd242e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Sat, 26 Apr 2025 14:02:36 +0200 Subject: [PATCH] Change: [Script] Reject scripts using negative version (#14096) --- src/ai/ai_info.cpp | 1 + src/game/game_info.cpp | 1 + src/script/script_info.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp index 79d5ca96dd..53bc27ef2b 100644 --- a/src/ai/ai_info.cpp +++ b/src/ai/ai_info.cpp @@ -66,6 +66,7 @@ template <> SQInteger PushClassName(HSQUIRRELVM vm) { sq if (info->engine->MethodExists(info->SQ_instance, "MinVersionToLoad")) { if (!info->engine->CallIntegerMethod(info->SQ_instance, "MinVersionToLoad", &info->min_loadable_version, MAX_GET_OPS)) return SQ_ERROR; + if (info->min_loadable_version < 0) return SQ_ERROR; } else { info->min_loadable_version = info->GetVersion(); } diff --git a/src/game/game_info.cpp b/src/game/game_info.cpp index 1045f01d82..cd26703069 100644 --- a/src/game/game_info.cpp +++ b/src/game/game_info.cpp @@ -57,6 +57,7 @@ template <> SQInteger PushClassName(HSQUIRRELVM vm) { if (info->engine->MethodExists(info->SQ_instance, "MinVersionToLoad")) { if (!info->engine->CallIntegerMethod(info->SQ_instance, "MinVersionToLoad", &info->min_loadable_version, MAX_GET_OPS)) return SQ_ERROR; + if (info->min_loadable_version < 0) return SQ_ERROR; } else { info->min_loadable_version = info->GetVersion(); } diff --git a/src/script/script_info.cpp b/src/script/script_info.cpp index 3963325b3d..540c126e05 100644 --- a/src/script/script_info.cpp +++ b/src/script/script_info.cpp @@ -62,6 +62,7 @@ bool ScriptInfo::CheckMethod(const char *name) const if (!info->engine->CallStringMethod(info->SQ_instance, "GetDescription", &info->description, MAX_GET_OPS)) return SQ_ERROR; if (!info->engine->CallStringMethod(info->SQ_instance, "GetDate", &info->date, MAX_GET_OPS)) return SQ_ERROR; if (!info->engine->CallIntegerMethod(info->SQ_instance, "GetVersion", &info->version, MAX_GET_OPS)) return SQ_ERROR; + if (info->version < 0) return SQ_ERROR; if (!info->engine->CallStringMethod(info->SQ_instance, "CreateInstance", &info->instance_name, MAX_CREATEINSTANCE_OPS)) return SQ_ERROR; /* The GetURL function is optional. */