Throw a specific exception for zlib decompression failure

This commit is contained in:
Dylan K. Taylor
2020-04-22 13:45:29 +01:00
parent 35d656c6e5
commit 843993f02b
3 changed files with 36 additions and 3 deletions

View File

@@ -35,6 +35,7 @@ use pocketmine\form\Form;
use pocketmine\math\Vector3;
use pocketmine\network\BadPacketException;
use pocketmine\network\mcpe\compression\CompressBatchPromise;
use pocketmine\network\mcpe\compression\DecompressionException;
use pocketmine\network\mcpe\compression\Zlib;
use pocketmine\network\mcpe\encryption\DecryptionException;
use pocketmine\network\mcpe\encryption\NetworkCipher;
@@ -280,7 +281,7 @@ class NetworkSession{
Timings::$playerNetworkReceiveDecompressTimer->startTiming();
try{
$stream = new PacketBatch(Zlib::decompress($payload));
}catch(\ErrorException $e){
}catch(DecompressionException $e){
$this->logger->debug("Failed to decompress packet: " . base64_encode($payload));
//TODO: this isn't incompatible game version if we already established protocol version
throw BadPacketException::wrap($e, "Compressed packet batch decode error");