diff --git a/src/world/format/io/data/BedrockWorldData.php b/src/world/format/io/data/BedrockWorldData.php index 5be66be8b..ad50b9ddd 100644 --- a/src/world/format/io/data/BedrockWorldData.php +++ b/src/world/format/io/data/BedrockWorldData.php @@ -111,8 +111,11 @@ class BedrockWorldData extends BaseNbtWorldData{ } protected function load() : CompoundTag{ - $rawLevelData = file_get_contents($this->dataPath); - if($rawLevelData === false or strlen($rawLevelData) <= 8){ + $rawLevelData = @file_get_contents($this->dataPath); + if($rawLevelData === false){ + throw new CorruptedWorldException("Failed to read level.dat (permission denied or doesn't exist)"); + } + if(strlen($rawLevelData) <= 8){ throw new CorruptedWorldException("Truncated level.dat"); } $nbt = new LittleEndianNbtSerializer(); diff --git a/src/world/format/io/data/JavaWorldData.php b/src/world/format/io/data/JavaWorldData.php index 2b7f45598..271728f5d 100644 --- a/src/world/format/io/data/JavaWorldData.php +++ b/src/world/format/io/data/JavaWorldData.php @@ -75,9 +75,13 @@ class JavaWorldData extends BaseNbtWorldData{ } protected function load() : CompoundTag{ + $rawLevelData = @file_get_contents($this->dataPath); + if($rawLevelData === false){ + throw new CorruptedWorldException("Failed to read level.dat (permission denied or doesn't exist)"); + } $nbt = new BigEndianNbtSerializer(); try{ - $worldData = $nbt->readCompressed(file_get_contents($this->dataPath))->mustGetCompoundTag(); + $worldData = $nbt->readCompressed($rawLevelData)->mustGetCompoundTag(); }catch(NbtDataException $e){ throw new CorruptedWorldException($e->getMessage(), 0, $e); }