protocol: specialize exception used for bad packets

This commit is contained in:
Dylan K. Taylor
2020-04-27 12:55:00 +01:00
parent f91e2f41e0
commit 15c744b0d7
15 changed files with 79 additions and 52 deletions

View File

@@ -63,6 +63,7 @@ use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
use pocketmine\network\mcpe\protocol\NetworkChunkPublisherUpdatePacket;
use pocketmine\network\mcpe\protocol\Packet;
use pocketmine\network\mcpe\protocol\PacketDecodeException;
use pocketmine\network\mcpe\protocol\PlayerListPacket;
use pocketmine\network\mcpe\protocol\PlayStatusPacket;
use pocketmine\network\mcpe\protocol\ServerboundPacket;
@@ -327,7 +328,11 @@ class NetworkSession{
$timings->startTiming();
try{
$packet->decode();
try{
$packet->decode();
}catch(PacketDecodeException $e){
throw BadPacketException::wrap($e);
}
$stream = $packet->getBinaryStream();
if(!$stream->feof()){
$remains = substr($stream->getBuffer(), $stream->getOffset());