From fe7f3a6f26a1e9fc14e97d98d8db1aa07819861d Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 22 Oct 2021 06:27:37 +0200 Subject: [PATCH] RiivolutionPatcher: Protect against three or more dots in path traversal. --- Source/Core/DiscIO/RiivolutionPatcher.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Core/DiscIO/RiivolutionPatcher.cpp b/Source/Core/DiscIO/RiivolutionPatcher.cpp index 8f1b88caf3..2e400507e1 100644 --- a/Source/Core/DiscIO/RiivolutionPatcher.cpp +++ b/Source/Core/DiscIO/RiivolutionPatcher.cpp @@ -98,6 +98,13 @@ FileDataLoaderHostFS::MakeAbsoluteFromRelative(std::string_view external_relativ result.pop_back(); result.pop_back(); } + else if (std::all_of(element.begin(), element.end(), [](char c) { return c == '.'; })) + { + // This is a triple, quadruple, etc. dot. + // Some file systems treat this as several 'up' path traversals, but Riivolution does not. + // If someone tries this just error out, it wouldn't work sensibly in Riivolution anyway. + return std::nullopt; + } else { // We're going down a level.