Merge branch 'stable'

This commit is contained in:
Dylan K. Taylor
2019-04-21 16:56:53 +01:00
3 changed files with 15 additions and 10 deletions

View File

@ -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);
}
/**

View File

@ -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){