diff --git a/src/pipeline/wowee_building.cpp b/src/pipeline/wowee_building.cpp index 18d76595..388f38bf 100644 --- a/src/pipeline/wowee_building.cpp +++ b/src/pipeline/wowee_building.cpp @@ -50,6 +50,7 @@ WoweeBuilding WoweeBuildingLoader::load(const std::string& basePath) { WoweeBuilding::Group grp; uint16_t gnLen; f.read(reinterpret_cast(&gnLen), 2); + if (gnLen > 1024) gnLen = 0; grp.name.resize(gnLen); f.read(grp.name.data(), gnLen); @@ -57,6 +58,13 @@ WoweeBuilding WoweeBuildingLoader::load(const std::string& basePath) { f.read(reinterpret_cast(&vc), 4); f.read(reinterpret_cast(&ic), 4); f.read(reinterpret_cast(&tc), 4); + // Per-group sanity. WMO groups cap at 65k vertices in practice + // (uint16 indices). Tex paths per group rarely exceed 16. + if (vc > 1'000'000 || ic > 4'000'000 || tc > 1024) { + LOG_ERROR("WOB group ", gi, " counts rejected (verts=", vc, + " indices=", ic, " textures=", tc, "): ", basePath); + return WoweeBuilding{}; + } uint8_t outdoor; f.read(reinterpret_cast(&outdoor), 1); grp.isOutdoor = (outdoor != 0);