mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-25 12:54:03 +00:00
sync NBT network string length cap
This commit is contained in:
parent
9b0b8b9a0c
commit
cfd4580388
@ -46,15 +46,11 @@ class NetworkNbtSerializer extends LittleEndianNbtSerializer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function readString() : string{
|
public function readString() : string{
|
||||||
return $this->buffer->get($this->buffer->getUnsignedVarInt());
|
return $this->buffer->get(self::checkReadStringLength($this->buffer->getUnsignedVarInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function writeString(string $v) : void{
|
public function writeString(string $v) : void{
|
||||||
$len = strlen($v);
|
$this->buffer->putUnsignedVarInt(self::checkWriteStringLength(strlen($v)));
|
||||||
if($len > 32767){
|
|
||||||
throw new \InvalidArgumentException("NBT strings cannot be longer than 32767 bytes, got $len bytes");
|
|
||||||
}
|
|
||||||
$this->buffer->putUnsignedVarInt($len);
|
|
||||||
$this->buffer->put($v);
|
$this->buffer->put($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user