From 1908ac5e92d6e520e452c973c1df625026c4a871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 6 Nov 2026 14:08:58 +0100 Subject: [PATCH] PSAR: Bound entries by the file size, not the declared size The last entry's contents can run past the size the header declares (1.x updaters, and the 4.21 and 5.70 PSARs), so the wraparound check from c5673294ab refused them. The file size is enough to stop the wrap. Co-Authored-By: Claude Opus 5.5 --- Core/Util/PSARUnpack.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/Util/PSARUnpack.cpp b/Core/Util/PSARUnpack.cpp index 56064df306..2ff1ed082d 100644 --- a/Core/Util/PSARUnpack.cpp +++ b/Core/Util/PSARUnpack.cpp @@ -699,7 +699,9 @@ int PSARReader::NextEntry(std::string *error) { const u32 chunkSize = ReadU32(block_.data() + 0x104); const u32 expandedSize = ReadU32(block_.data() + 0x108); // pos_ is a u32, so a huge chunk would wrap it back to an earlier entry and loop forever. - if (chunkSize > limit_ - std::min((size_t)pos_, limit_)) { + // Check against the file, not limit_: the last entry's contents can run past the size the + // header declares (1.x updaters, and the 3.60, 4.21 and 5.70 PSARs). + if (chunkSize > size_ - std::min((size_t)pos_, size_)) { *error = StringFromFormat("Entry '%s' runs past the end of the archive (%u bytes)", entryName_.c_str(), chunkSize); return -1; }