RegionLocationTableEntry: cap firstSector at 16777216

this is the biggest sector start that the location table can represent, due to the binary format. Larger values than this will overflow and cause corruption.
This provides an effective limit of 64 GB on region files.
This commit is contained in:
Dylan K. Taylor 2020-06-15 13:23:08 +01:00
parent d38709a7ae
commit bb2685ca65

View File

@ -38,7 +38,7 @@ class RegionLocationTableEntry{
* @throws \InvalidArgumentException
*/
public function __construct(int $firstSector, int $sectorCount, int $timestamp){
if($firstSector < 0){
if($firstSector < 0 or $firstSector >= 2 ** 24){
throw new \InvalidArgumentException("Start sector must be positive, got $firstSector");
}
$this->firstSector = $firstSector;