mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Merge branch 'stable'
This commit is contained in:
@ -37,12 +37,13 @@ final class NetworkCompression{
|
||||
|
||||
/**
|
||||
* @param string $payload
|
||||
* @param int $maxDecodedLength default 2MB
|
||||
*
|
||||
* @return string
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public static function decompress(string $payload) : string{
|
||||
return zlib_decode($payload, 1024 * 1024 * 64); //Max 64MB
|
||||
public static function decompress(string $payload, int $maxDecodedLength = 1024 * 1024 * 2) : string{
|
||||
return zlib_decode($payload, $maxDecodedLength);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -260,7 +260,11 @@ class NetworkSession{
|
||||
Timings::$playerNetworkReceiveDecompressTimer->stopTiming();
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
while(!$stream->feof() and $this->connected){
|
||||
if($count++ >= 500){
|
||||
throw new BadPacketException("Too many packets in a single batch");
|
||||
}
|
||||
try{
|
||||
$pk = PacketPool::getPacket($stream->getString());
|
||||
}catch(BinaryDataException $e){
|
||||
|
Reference in New Issue
Block a user