mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 01:39:52 +00:00
fix crash on invalid NBT during itemstack decoding
This commit is contained in:
parent
3d8cd54f16
commit
ece4d99c1e
@ -31,6 +31,7 @@ use pocketmine\item\ItemFactory;
|
|||||||
use pocketmine\item\ItemIds;
|
use pocketmine\item\ItemIds;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
|
use pocketmine\nbt\NbtDataException;
|
||||||
use pocketmine\nbt\TreeRoot;
|
use pocketmine\nbt\TreeRoot;
|
||||||
use pocketmine\network\BadPacketException;
|
use pocketmine\network\BadPacketException;
|
||||||
use pocketmine\network\mcpe\protocol\types\CommandOriginData;
|
use pocketmine\network\mcpe\protocol\types\CommandOriginData;
|
||||||
@ -105,7 +106,11 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
if($c !== 1){
|
if($c !== 1){
|
||||||
throw new BadPacketException("Unexpected NBT count $c");
|
throw new BadPacketException("Unexpected NBT count $c");
|
||||||
}
|
}
|
||||||
$compound = (new NetworkNbtSerializer())->read($this->buffer, $this->offset, 512)->getTag();
|
try{
|
||||||
|
$compound = (new NetworkNbtSerializer())->read($this->buffer, $this->offset, 512)->getTag();
|
||||||
|
}catch(NbtDataException $e){
|
||||||
|
throw new BadPacketException($e->getMessage(), 0, $e);
|
||||||
|
}
|
||||||
}elseif($nbtLen !== 0){
|
}elseif($nbtLen !== 0){
|
||||||
throw new BadPacketException("Unexpected fake NBT length $nbtLen");
|
throw new BadPacketException("Unexpected fake NBT length $nbtLen");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user