mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 17:13:51 +00:00
fix(whm): reject load on overlong per-chunk alphaSize
Same load-desync pattern as elsewhere — alphaSize > 65536 silently skipped the read but the actual alpha bytes were still on disk, so the next chunk's baseHeight float read would parse alpha bytes. Now rejects the load with LOG_ERROR.
This commit is contained in:
parent
9facea14a7
commit
64b85ff9ff
1 changed files with 10 additions and 2 deletions
|
|
@ -58,9 +58,17 @@ bool WoweeTerrainLoader::loadHeightmap(const std::string& whmPath, ADTTerrain& t
|
|||
if (!std::isfinite(h)) h = 0.0f;
|
||||
}
|
||||
|
||||
// Read alpha map data (may not be present in older WHM files)
|
||||
// Read alpha map data (may not be present in older WHM files).
|
||||
// Reject overlong alphaSize to keep the per-chunk block alignment —
|
||||
// skipping a 100MB alpha block would leave the next chunk's
|
||||
// baseHeight read parsing alpha bytes as floats.
|
||||
uint32_t alphaSize = 0;
|
||||
if (f.read(reinterpret_cast<char*>(&alphaSize), 4) && alphaSize > 0 && alphaSize <= 65536) {
|
||||
if (f.read(reinterpret_cast<char*>(&alphaSize), 4) && alphaSize > 0) {
|
||||
if (alphaSize > 65536) {
|
||||
LOG_ERROR("WHM chunk ", ci, " alphaSize rejected (",
|
||||
alphaSize, "): ", whmPath);
|
||||
return false;
|
||||
}
|
||||
chunk.alphaMap.resize(alphaSize);
|
||||
f.read(reinterpret_cast<char*>(chunk.alphaMap.data()), alphaSize);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue