SPU LLVM: Fix crashes on corrupted cache file

* Fix OOM if size is too high.
* Fix out-of-bounds access beyond SPU_LS_SIZE.
This commit is contained in:
Eladash 2023-09-02 09:29:58 +03:00 committed by Elad Ashkenazi
parent deacf76ca4
commit 3f7afb8375

View File

@ -588,9 +588,12 @@ std::deque<spu_program> spu_cache::get()
break;
}
func.resize(size);
if (utils::add_saturate<u32>(addr, utils::mul_saturate<u32>(size, 4)) > SPU_LS_SIZE)
{
break;
}
if (m_file.read(func.data(), func.size() * 4) != func.size() * 4)
if (!m_file.read(func, size))
{
break;
}