summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/FileSystemGCWii.cpp
diff options
context:
space:
mode:
authorMarkus Wick <degasus@users.noreply.github.com>2015-11-18 10:43:47 +0100
committerMarkus Wick <degasus@users.noreply.github.com>2015-11-18 10:43:47 +0100
commit584ea8b3205f703b09f7f030493150e9e526b604 (patch)
tree98468927e7572335c44182a7017d93a4777c42b0 /Source/Core/DiscIO/FileSystemGCWii.cpp
parentf172cda50f3918ebbb033ec23890358706033f0f (diff)
parent6c25c633014ce8bdf8b8a4d9562aca646ba5f051 (diff)
Merge pull request #3206 from JosJuice/limit-filesystem-size-2
Limit size of loaded file systems
Diffstat (limited to 'Source/Core/DiscIO/FileSystemGCWii.cpp')
-rw-r--r--Source/Core/DiscIO/FileSystemGCWii.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/Core/DiscIO/FileSystemGCWii.cpp b/Source/Core/DiscIO/FileSystemGCWii.cpp
index b03edceb54..02fb360bbe 100644
--- a/Source/Core/DiscIO/FileSystemGCWii.cpp
+++ b/Source/Core/DiscIO/FileSystemGCWii.cpp
@@ -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;