mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-19 18:04:07 +00:00
Fixed server crash on truncated varint in packet header
This commit is contained in:
parent
dff13a884f
commit
8dd61df7ac
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol\serializer;
|
|||||||
use pocketmine\network\mcpe\protocol\Packet;
|
use pocketmine\network\mcpe\protocol\Packet;
|
||||||
use pocketmine\network\mcpe\protocol\PacketDecodeException;
|
use pocketmine\network\mcpe\protocol\PacketDecodeException;
|
||||||
use pocketmine\network\mcpe\protocol\PacketPool;
|
use pocketmine\network\mcpe\protocol\PacketPool;
|
||||||
|
use pocketmine\utils\BinaryDataException;
|
||||||
|
|
||||||
class PacketBatch{
|
class PacketBatch{
|
||||||
|
|
||||||
@ -44,7 +45,11 @@ class PacketBatch{
|
|||||||
public function getPackets(PacketPool $packetPool, int $max) : \Generator{
|
public function getPackets(PacketPool $packetPool, int $max) : \Generator{
|
||||||
$serializer = new PacketSerializer($this->buffer);
|
$serializer = new PacketSerializer($this->buffer);
|
||||||
for($c = 0; $c < $max and !$serializer->feof(); ++$c){
|
for($c = 0; $c < $max and !$serializer->feof(); ++$c){
|
||||||
yield $c => $packetPool->getPacket($serializer->getString());
|
try{
|
||||||
|
yield $c => $packetPool->getPacket($serializer->getString());
|
||||||
|
}catch(BinaryDataException $e){
|
||||||
|
throw new PacketDecodeException("Error decoding packet $c of batch: " . $e->getMessage(), 0, $e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(!$serializer->feof()){
|
if(!$serializer->feof()){
|
||||||
throw new PacketDecodeException("Reached limit of $max packets in a single batch");
|
throw new PacketDecodeException("Reached limit of $max packets in a single batch");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user