diff --git a/Common/Thread/ThreadManager.cpp b/Common/Thread/ThreadManager.cpp index aea8b7558e..98e0b43a57 100644 --- a/Common/Thread/ThreadManager.cpp +++ b/Common/Thread/ThreadManager.cpp @@ -304,7 +304,7 @@ void ThreadManager::EnqueueTask(Task *task) { void ThreadManager::EnqueueTaskOnThread(int threadNum, Task *task) { _assert_msg_(task->Type() != TaskType::DEDICATED_THREAD, "Dedicated thread tasks can't be put on specific threads"); - _assert_msg_(threadNum >= 0 && threadNum < (int)global_->threads_.size(), "Bad threadnum or not initialized"); + _assert_msg_(threadNum >= 0 && threadNum < (int)global_->threads_.size(), "Bad threadnum %d(/%d) or not initialized", threadNum, (int)global_->threads_.size()); TaskThreadContext *thread = global_->threads_[threadNum]; size_t queueIndex = (size_t)task->Priority(); diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index f62fcdda5c..e877d0ac7c 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -68,8 +68,8 @@ bool ElfReader::LoadRelocations(const Elf32_Rel *rels, int numRelocs) { std::atomic numErrors; numErrors.store(0); - ParallelRangeLoop(&g_threadManager, [&](int l, int h) { - for (int r = l; r < h; r++) { + { + for (int r = 0; r < numRelocs; r++) { u32 info = rels[r].r_info; u32 addr = rels[r].r_offset; @@ -100,10 +100,8 @@ bool ElfReader::LoadRelocations(const Elf32_Rel *rels, int numRelocs) { relocOps[r] = Memory::ReadUnchecked_Instruction(addr, true).encoding; } - }, 0, numRelocs, 128, TaskPriority::HIGH); - ParallelRangeLoop(&g_threadManager, [&](int l, int h) { - for (int r = l; r < h; r++) { + for (int r = 0; r < numRelocs; r++) { VERBOSE_LOG(Log::Loader, "Loading reloc %i (%p)...", r, rels + r); u32 info = rels[r].r_info; u32 addr = rels[r].r_offset; @@ -233,7 +231,7 @@ bool ElfReader::LoadRelocations(const Elf32_Rel *rels, int numRelocs) { Memory::WriteUnchecked_U32(op, addr); NotifyMemInfo(MemBlockFlags::WRITE, addr, 4, "Relocation"); } - }, 0, numRelocs, 128, TaskPriority::HIGH); + } if (numErrors) { WARN_LOG(Log::Loader, "%i bad relocations found!!!", numErrors.load()); diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 268b3ce172..748d8c29bd 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1085,6 +1085,14 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load // In this case it's definitely not compressed. Added assert below. } + // Don't accept ELFs over 32MB. + if (decryptedSize > 32 * 1024 * 1024) { + *error_string = StringFromFormat("ELF/PRX corrupt, unreasonable decrypted size: %d", (u32)decryptedSize); + // TODO: Might be the wrong error code. + error = SCE_KERNEL_ERROR_FILEERR; + return nullptr; + } + // decompress if required. if (isGzip) { _dbg_assert_(Read32(ptr + 0x150) != ELF_MAGIC); diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index a442202f43..d83e90b5f1 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -1370,7 +1370,7 @@ bool PPGeImage::Load() { width_ = 0; height_ = 0; - unsigned char *textureData; + unsigned char *textureData = nullptr; int success; if (filename_.empty()) { _dbg_assert_(size_ < MAX_VALID_IMAGE_SIZE); diff --git a/GPU/Common/TextureReplacer.cpp b/GPU/Common/TextureReplacer.cpp index 41f9a0cc08..9636d104ac 100644 --- a/GPU/Common/TextureReplacer.cpp +++ b/GPU/Common/TextureReplacer.cpp @@ -790,6 +790,7 @@ void TextureReplacer::NotifyTextureDecoded(ReplacedTexture *texture, const Repla _assert_msg_(saveEnabled_, "Texture saving not enabled"); _assert_(srcPitch >= 0); _assert_(data); + _assert_(level >= 0); if (!WillSave(replacedInfo)) { // Ignore.