summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/VolumeDirectory.cpp
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2015-01-10 12:17:15 +1100
committerskidau <skidau@gmail.com>2015-01-10 12:17:15 +1100
commit1e39fd825d05bbbda863a961c8bb1c70477a4504 (patch)
tree534861fecaad51cd243e46bbbd0d073336e0157e /Source/Core/DiscIO/VolumeDirectory.cpp
parent27300d5d59cb4bb05a442eeaaf0009297cdcbf82 (diff)
parent358183e34a037514b2889d5a7fac64b64a837780 (diff)
Merge pull request #1860 from JosJuice/volumedirectory-regression
Fix 4.0-4901 VolumeDirectory stack overflow
Diffstat (limited to 'Source/Core/DiscIO/VolumeDirectory.cpp')
-rw-r--r--Source/Core/DiscIO/VolumeDirectory.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Source/Core/DiscIO/VolumeDirectory.cpp b/Source/Core/DiscIO/VolumeDirectory.cpp
index 9c88f3c415..10a3e51f05 100644
--- a/Source/Core/DiscIO/VolumeDirectory.cpp
+++ b/Source/Core/DiscIO/VolumeDirectory.cpp
@@ -66,9 +66,12 @@ bool CVolumeDirectory::IsValidDirectory(const std::string& _rDirectory)
bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const
{
- bool wii = VolumeHandler::IsWii();
+ // VolumeHandler::IsWii is used here to check whether a Wii disc is used.
+ // That function calls this function to check a magic word in the disc header,
+ // so it is important that VolumeHandler::IsWii is not called when the header
+ // is being read with decrypt=false, as it would result in a stack overflow.
- if (!decrypt && (_Offset + _Length >= 0x400) && wii)
+ if (!decrypt && (_Offset + _Length >= 0x400) && VolumeHandler::IsWii())
{
// Fully supporting this would require re-encrypting every file that's read.
// Only supporting the areas that IOS allows software to read could be more feasible.
@@ -78,7 +81,7 @@ bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt
return false;
}
- if (decrypt && !wii)
+ if (decrypt && !VolumeHandler::IsWii())
PanicAlertT("Tried to decrypt data from a non-Wii volume");
// header