Core/PlayerDump: Add config to disallow overwriting existing files and usage of paths in player dump write to prevent local exploits

This commit is contained in:
Shocker
2011-10-08 16:56:04 +03:00
parent 40ed37c1e7
commit 0b243dfd9b
4 changed files with 29 additions and 0 deletions
+9
View File
@@ -352,6 +352,15 @@ bool PlayerDumpWriter::GetDump(uint32 guid, std::string &dump)
DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid)
{
if (sWorld->getBoolConfig(CONFIG_PDUMP_NO_PATHS))
if (strstr(file.c_str(), "\\") || strstr(file.c_str(), "/"))
return DUMP_FILE_OPEN_ERROR;
if (sWorld->getBoolConfig(CONFIG_PDUMP_NO_OVERWRITE))
if (FILE* f = fopen(file.c_str(), "r"))
{
fclose(f);
return DUMP_FILE_OPEN_ERROR;
}
FILE* fout = fopen(file.c_str(), "w");
if (!fout)
return DUMP_FILE_OPEN_ERROR;