From 01719de69637f3035a16086552c75b1c88a9e0de Mon Sep 17 00:00:00 2001 From: Slurmlord Date: Fri, 20 Jun 2025 17:04:22 +0200 Subject: [PATCH 1/2] Downgrade assertion to log for when a file is not under a specific base path. --- Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp | 2 +- GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp b/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp index 65e31318951..4462c779048 100644 --- a/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp @@ -367,7 +367,7 @@ Bool FileSystem::isPathInDirectory(const AsciiString& testPath, const AsciiStrin if (!testPathNormalized.startsWith(basePathNormalized)) #endif { - DEBUG_CRASH(("Normalized file path for '%s': '%s' was outside the expected base path of '%s' (normalized: '%s').\n", testPath.str(), testPathNormalized.str(), basePath.str(), basePathNormalized.str())); + DEBUG_LOG(("Normalized file path for '%s': '%s' was outside the expected base path of '%s' (normalized: '%s').\n", testPath.str(), testPathNormalized.str(), basePath.str(), basePathNormalized.str())); return false; } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp index 4f8a7d63b3f..144c265044a 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp @@ -384,7 +384,7 @@ Bool FileSystem::isPathInDirectory(const AsciiString& testPath, const AsciiStrin if (!testPathNormalized.startsWith(basePathNormalized)) #endif { - DEBUG_CRASH(("Normalized file path for '%s': '%s' was outside the expected base path of '%s' (normalized: '%s').\n", testPath.str(), testPathNormalized.str(), basePath.str(), basePathNormalized.str())); + DEBUG_LOG(("Normalized file path for '%s': '%s' was outside the expected base path of '%s' (normalized: '%s').\n", testPath.str(), testPathNormalized.str(), basePath.str(), basePathNormalized.str())); return false; } From f17511f7d9a246176221687cd8aa5cf9ddaf33d0 Mon Sep 17 00:00:00 2001 From: Slurmlord Date: Fri, 20 Jun 2025 17:46:56 +0200 Subject: [PATCH 2/2] Move debug logging out of FileSystem isPathInDirectory, into GameState instead. --- Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp | 1 - .../Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp | 1 + GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp | 1 - .../Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp | 1 + 4 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp b/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp index 4462c779048..1952bcd1589 100644 --- a/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp @@ -367,7 +367,6 @@ Bool FileSystem::isPathInDirectory(const AsciiString& testPath, const AsciiStrin if (!testPathNormalized.startsWith(basePathNormalized)) #endif { - DEBUG_LOG(("Normalized file path for '%s': '%s' was outside the expected base path of '%s' (normalized: '%s').\n", testPath.str(), testPathNormalized.str(), basePath.str(), basePathNormalized.str())); return false; } diff --git a/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp b/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp index 91e4f9aa315..cb85e81dbcb 100644 --- a/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp @@ -936,6 +936,7 @@ AsciiString GameState::portableMapPathToRealMapPath(const AsciiString& in) const if (!FileSystem::isPathInDirectory(prefix, containingBasePath)) { + DEBUG_LOG(("Normalized file path for '%s' was outside the expected base path of '%s'.\n", prefix.str(), containingBasePath.str())); return AsciiString::TheEmptyString; } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp index 144c265044a..aed60a6b17c 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp @@ -384,7 +384,6 @@ Bool FileSystem::isPathInDirectory(const AsciiString& testPath, const AsciiStrin if (!testPathNormalized.startsWith(basePathNormalized)) #endif { - DEBUG_LOG(("Normalized file path for '%s': '%s' was outside the expected base path of '%s' (normalized: '%s').\n", testPath.str(), testPathNormalized.str(), basePath.str(), basePathNormalized.str())); return false; } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp index ffc33ea9abc..fd2de28eb16 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp @@ -936,6 +936,7 @@ AsciiString GameState::portableMapPathToRealMapPath(const AsciiString& in) const if (!FileSystem::isPathInDirectory(prefix, containingBasePath)) { + DEBUG_LOG(("Normalized file path for '%s' was outside the expected base path of '%s'.\n", prefix.str(), containingBasePath.str())); return AsciiString::TheEmptyString; }