mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 19:37:17 +00:00
RegionLoader: do not attempt to auto-repair chunks with oversized lengths
In the old days, we used to try to correct this problem by adjusting the region header to match the length found at the start of the chunk payload. However, this has a very good chance to cause corruption of other chunks, since we can't do any fast overlap checks (an upsize might cause the chunk's alloocated area to overlap into another one, causing corruption when either chunk's space gets written to). This corruption risk has become more problematic since the introduction of region garbage sector reuse, since a broken location header could cause chunks to trash each others' saved data. In addition, if there is a length mismatch, there's a good chance that the oversized chunk itself will already be corrupted, so we'd just fail trying to decompress it later on. So, instead of trying to fix this automatically, we bail and hope this doesn't occur often enough for users to get upset, and allow external offline tools to attempt to repair the mess instead.
This commit is contained in:
parent
873e8740e0
commit
dea75a0687
@ -27,7 +27,6 @@ use pocketmine\level\format\ChunkException;
|
||||
use pocketmine\level\format\io\exception\CorruptedChunkException;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use function assert;
|
||||
use function ceil;
|
||||
use function chr;
|
||||
@ -160,10 +159,7 @@ class RegionLoader{
|
||||
}
|
||||
|
||||
if($length > ($this->locationTable[$index]->getSectorCount() << 12)){ //Invalid chunk, bigger than defined number of sectors
|
||||
MainLogger::getLogger()->error("Chunk x=$x,z=$z length mismatch (expected " . ($this->locationTable[$index]->getSectorCount() << 12) . " sectors, got $length sectors)");
|
||||
$old = $this->locationTable[$index];
|
||||
$this->locationTable[$index] = new RegionLocationTableEntry($old->getFirstSector(), $length >> 12, time());
|
||||
$this->writeLocationIndex($index);
|
||||
throw new CorruptedChunkException("Chunk length mismatch (expected " . ($this->locationTable[$index]->getSectorCount() << 12) . " sectors, got $length sectors)");
|
||||
}
|
||||
|
||||
$chunkData = fread($this->filePointer, $length);
|
||||
|
Loading…
x
Reference in New Issue
Block a user