mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 11:27:07 +00:00
Detect really big corrupted chunks, closes #2471
This commit is contained in:
parent
767800662c
commit
95b305ce87
@ -88,6 +88,12 @@ class RegionLoader extends \pocketmine\level\format\mcregion\RegionLoader{
|
||||
$compression = ord(fgetc($this->filePointer));
|
||||
}
|
||||
|
||||
if($length >= self::MAX_SECTOR_LENGTH){
|
||||
MainLogger::getLogger()->error("Corrupted chunk header detected");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if($length > ($this->locationTable[$index][1] << 12)){ //Invalid chunk, bigger than defined number of sectors
|
||||
MainLogger::getLogger()->error("Corrupted chunk detected");
|
||||
$this->locationTable[$index][1] = $length >> 12;
|
||||
|
@ -38,6 +38,7 @@ class RegionLoader{
|
||||
const VERSION = 1;
|
||||
const COMPRESSION_GZIP = 1;
|
||||
const COMPRESSION_ZLIB = 2;
|
||||
const MAX_SECTOR_LENGTH = 32 << 12; //32 sectors
|
||||
public static $COMPRESSION_LEVEL = 7;
|
||||
|
||||
protected $x;
|
||||
@ -109,6 +110,12 @@ class RegionLoader{
|
||||
$compression = ord(fgetc($this->filePointer));
|
||||
}
|
||||
|
||||
if($length >= self::MAX_SECTOR_LENGTH){
|
||||
MainLogger::getLogger()->error("Corrupted chunk header detected");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if($length > ($this->locationTable[$index][1] << 12)){ //Invalid chunk, bigger than defined number of sectors
|
||||
MainLogger::getLogger()->error("Corrupted bigger chunk detected");
|
||||
$this->locationTable[$index][1] = $length >> 12;
|
||||
|
Loading…
x
Reference in New Issue
Block a user