From 377cfb32d3c41d8346cfe7b1b12bc360617e0ce0 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 09:35:49 -0700 Subject: [PATCH] fix(wcp): cap per-file size at pack to match unpack limit (256MB) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pack previously accepted any file < 4GB and wrote it raw. Unpack caps at 256MB and rejects the whole archive on overflow — so a huge file in the source dir would silently produce an unpackable WCP. Cap at pack and skip the body (size=0 entry) so the rest of the pack remains usable. --- tools/editor/content_pack.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/editor/content_pack.cpp b/tools/editor/content_pack.cpp index ff5cb262..9946a51b 100644 --- a/tools/editor/content_pack.cpp +++ b/tools/editor/content_pack.cpp @@ -93,8 +93,13 @@ bool ContentPacker::packZone(const std::string& outputDir, const std::string& ma std::ifstream fin(full, std::ios::binary | std::ios::ate); std::streamsize sz = fin.tellg(); - if (sz < 0 || static_cast(sz) > 0xFFFFFFFFull) { - LOG_ERROR("WCP skipped file (size out of range): ", rel); + // Cap at the unpack-side per-file limit (256MB) so we never write + // a pack the loader will reject as a whole. Files that big are + // almost certainly an authoring mistake — log + skip the body + // instead of producing an unpackable archive. + constexpr uint64_t kMaxFileBytes = 256ull * 1024 * 1024; + if (sz < 0 || static_cast(sz) > kMaxFileBytes) { + LOG_ERROR("WCP skipped file (size ", sz, " > 256MB cap): ", rel); uint32_t zero = 0; out.write(reinterpret_cast(&zero), 4); continue;