fix(wcp): skip out-of-tree files at pack time

fs::relative can return '../foo' when the pack source is a symlink
that resolves outside the pack root. The unpacker rejects '..' or
absolute paths wholesale, so a single rogue symlink would ruin the
whole archive. Skip the offending file at pack with a warning so
the rest of the zone still ships.
This commit is contained in:
Kelsi 2026-05-06 09:47:49 -07:00
parent 2f56941ad2
commit 6b82196b7d

View file

@ -46,6 +46,14 @@ bool ContentPacker::packZone(const std::string& outputDir, const std::string& ma
}
std::string rel = fs::relative(entry.path(), srcDir).string();
std::replace(rel.begin(), rel.end(), '\\', '/');
// fs::relative can return "../foo" when srcDir is a symlink that
// resolves outside the pack root; reject those before they're
// baked into a WCP that the unpacker will then refuse wholesale.
if (rel.find("..") != std::string::npos ||
(!rel.empty() && rel[0] == '/')) {
LOG_WARNING("WCP skipping out-of-tree file: ", entry.path().string());
continue;
}
files.push_back({rel, entry.path().string()});
}