Merge pull request #3206 from JosJuice/limit-filesystem-size-2

Limit size of loaded file systems
This commit is contained in:
Markus Wick 2015-11-18 10:43:47 +01:00
commit 584ea8b320
1 changed files with 12 additions and 0 deletions

View File

@ -270,6 +270,18 @@ void CFileSystemGCWii::InitFileSystem()
if (!Root.IsDirectory())
return;
// 12 bytes (the size of a file entry) times 10 * 1024 * 1024 is 120 MiB,
// more than total RAM in a Wii. No file system should use anywhere near that much.
static const u32 ARBITRARY_FILE_SYSTEM_SIZE_LIMIT = 10 * 1024 * 1024;
if (Root.m_FileSize > ARBITRARY_FILE_SYSTEM_SIZE_LIMIT)
{
// Without this check, Dolphin can crash by trying to allocate too much
// memory when loading the file systems of certain malformed disc images.
ERROR_LOG(DISCIO, "File system is abnormally large! Aborting loading");
return;
}
if (m_FileInfoVector.size())
PanicAlert("Wtf?");
u64 NameTableOffset = FSTOffset;