[IO]: Disable directory traversal (#863)
This commit is contained in:
parent
b89dd52118
commit
5a1c92c762
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user