mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 17:43:51 +00:00
fix(wob): reject load on out-of-range material count
Previously load silently skipped the materials block when mc > 256, leaving the file pointer right after the count — the next group's name would then read material bytes as garbage and the rest of the file would shift. Save now caps at 256 (so the asymmetry shouldn't trigger from our own writer), but a hand-crafted or future-version WoB could still hit it.
This commit is contained in:
parent
0bf7c8ac3f
commit
17f67e3ec8
1 changed files with 10 additions and 2 deletions
|
|
@ -115,9 +115,17 @@ WoweeBuilding WoweeBuildingLoader::load(const std::string& basePath) {
|
|||
grp.texturePaths.push_back(tp);
|
||||
}
|
||||
|
||||
// Read material data (v1.1+)
|
||||
// Read material data (v1.1+). Reject the whole load on a count
|
||||
// overflow rather than silently dropping the materials and leaving
|
||||
// the file pointer misaligned (next group's name would read
|
||||
// material bytes as garbage).
|
||||
uint32_t mc = 0;
|
||||
if (f.read(reinterpret_cast<char*>(&mc), 4) && mc > 0 && mc <= 256) {
|
||||
if (f.read(reinterpret_cast<char*>(&mc), 4) && mc > 0) {
|
||||
if (mc > 256) {
|
||||
LOG_ERROR("WOB group ", gi, " material count rejected (",
|
||||
mc, "): ", basePath);
|
||||
return WoweeBuilding{};
|
||||
}
|
||||
for (uint32_t mi = 0; mi < mc; mi++) {
|
||||
WoweeBuilding::Material mat;
|
||||
uint16_t pl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue