From 9d8ed764c186de5d3076ca7179e27cd37fcb2ec2 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Wed, 5 Mar 2025 22:46:21 +0100 Subject: [PATCH] Osiris: only load first-party scripts Disable loading scripts (.dll,.so,.dylib) from .mn3 files, to avoid 3rd-party levels abusing the scripting system. These scripts, compiled for Win32, would not work anyway. The only scripts we want to load are first-party scripts that we compile as part of 'd3-.hog'. --- Descent3/Mission.cpp | 7 ++++++- Descent3/OsirisLoadandBind.cpp | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Descent3/Mission.cpp b/Descent3/Mission.cpp index 9180c0dc..e0997c49 100644 --- a/Descent3/Mission.cpp +++ b/Descent3/Mission.cpp @@ -670,6 +670,7 @@ #include "BOA.h" #include "terrain.h" #include "multi.h" +#include "module.h" #include "hud.h" #include "localization.h" #include "levelgoal.h" @@ -1780,7 +1781,11 @@ bool mn3_Open(const std::filesystem::path &mn3file) { if (mn3_handle == 0) { return false; } else { - Osiris_ExtractScriptsFromHog(mn3_handle, true); + /* Disabled loading scripts from .mn3 files on purpose: + all 64-bit first-party level scripts have already been loaded from `PRIMARY_HOG`. + Mission files contain only Win32 scripts by default, which cannot not be loaded on 64-bit builds. + Reactivate this when we have a proper sandbox system to safely run third-party scripts contained in user-made levels. */ + // Osiris_ExtractScriptsFromHog(mn3_handle, true); } // do table file stuff. std::filesystem::path filename = mn3file.stem(); diff --git a/Descent3/OsirisLoadandBind.cpp b/Descent3/OsirisLoadandBind.cpp index a1bd4e71..d0994fe5 100644 --- a/Descent3/OsirisLoadandBind.cpp +++ b/Descent3/OsirisLoadandBind.cpp @@ -921,7 +921,10 @@ int get_full_path_to_module(const std::filesystem::path &module_name, std::files fullpath = OSIRIS_Extracted_script_dir / OSIRIS_Extracted_scripts[basename].temp_filename; return 0; } - Int3(); // this file was supposed to exist + + // Script was not found in extracted scripts, + // we are possibly looking for a script in a 3rd-party level, which we do not want to load + return -2; } break; default: fullpath.clear();