[IO]: Disable directory traversal (#863)

This commit is contained in:
Edo 2023-03-21 21:01:58 +00:00 committed by GitHub
parent b89dd52118
commit 5a1c92c762
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,15 @@ namespace Components::GSC
const auto* filepath = Game::Scr_GetString(0);
const auto* mode = Game::Scr_GetString(1);
for (std::size_t i = 0; i < std::extent_v<decltype(ForbiddenStrings)>; ++i)
{
if (std::strstr(filepath, ForbiddenStrings[i]) != nullptr)
{
Logger::PrintError(Game::CON_CHANNEL_PARSERSCRIPT, "OpenFile: directory traversal is not allowed!\n");
return;
}
}
if (mode != "read"s)
{
Logger::PrintError(Game::CON_CHANNEL_PARSERSCRIPT, "Valid openfile modes are 'read'\n");