Prevent access to /Save/Preferences.ini from lua

Directly writing to the file would circumvent preference protections,
compromising security.
This commit is contained in:
Martin Natano
2022-05-07 23:53:58 +02:00
parent b9ebbd32a9
commit d54bc6857f
4 changed files with 71 additions and 59 deletions
+9
View File
@@ -1,5 +1,8 @@
#ifndef RAGE_FILE_MANAGER_H
#define RAGE_FILE_MANAGER_H
#include <unordered_set>
/** @brief Constants for working with the RageFileManager. */
namespace RageFileManagerUtil
{
@@ -74,12 +77,18 @@ public:
bool Unzip(const std::string &zipPath, std::string targetPath, int strip);
// path protection
void ProtectPath(const std::string& path);
bool IsPathProtected(const std::string& path);
// Lua
void PushSelf( lua_State *L );
private:
RageFileBasic *OpenForReading( const RString &sPath, int iMode, int &iError );
RageFileBasic *OpenForWriting( const RString &sPath, int iMode, int &iError );
std::unordered_set<std::string> m_protectedPaths;
};
extern RageFileManager *FILEMAN;