Merge branch 'stable'

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

16
composer.lock generated
View File

@ -333,12 +333,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/Math.git", "url": "https://github.com/pmmp/Math.git",
"reference": "1bf44397897d8e50d747e9e7a3de245c21b464c9" "reference": "52a92d6d5c665528a9fc597b1f10d6e15e7d861a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/Math/zipball/1bf44397897d8e50d747e9e7a3de245c21b464c9", "url": "https://api.github.com/repos/pmmp/Math/zipball/52a92d6d5c665528a9fc597b1f10d6e15e7d861a",
"reference": "1bf44397897d8e50d747e9e7a3de245c21b464c9", "reference": "52a92d6d5c665528a9fc597b1f10d6e15e7d861a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -364,7 +364,7 @@
"source": "https://github.com/pmmp/Math/tree/master", "source": "https://github.com/pmmp/Math/tree/master",
"issues": "https://github.com/pmmp/Math/issues" "issues": "https://github.com/pmmp/Math/issues"
}, },
"time": "2019-01-04T15:49:39+00:00" "time": "2019-04-18T18:03:11+00:00"
}, },
{ {
"name": "pocketmine/nbt", "name": "pocketmine/nbt",
@ -413,12 +413,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/RakLib.git", "url": "https://github.com/pmmp/RakLib.git",
"reference": "c2d5262d10e1b25f764f2e8ea09e1e3d0e578b72" "reference": "34a7600d6b4124ecbbc1654cb2dab0d1342a5622"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/c2d5262d10e1b25f764f2e8ea09e1e3d0e578b72", "url": "https://api.github.com/repos/pmmp/RakLib/zipball/34a7600d6b4124ecbbc1654cb2dab0d1342a5622",
"reference": "c2d5262d10e1b25f764f2e8ea09e1e3d0e578b72", "reference": "34a7600d6b4124ecbbc1654cb2dab0d1342a5622",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -446,7 +446,7 @@
"source": "https://github.com/pmmp/RakLib/tree/master", "source": "https://github.com/pmmp/RakLib/tree/master",
"issues": "https://github.com/pmmp/RakLib/issues" "issues": "https://github.com/pmmp/RakLib/issues"
}, },
"time": "2019-03-24T16:57:27+00:00" "time": "2019-04-21T13:19:16+00:00"
}, },
{ {
"name": "pocketmine/snooze", "name": "pocketmine/snooze",

View File

@ -37,12 +37,13 @@ final class NetworkCompression{
/** /**
* @param string $payload * @param string $payload
* @param int $maxDecodedLength default 2MB
* *
* @return string * @return string
* @throws \ErrorException * @throws \ErrorException
*/ */
public static function decompress(string $payload) : string{ public static function decompress(string $payload, int $maxDecodedLength = 1024 * 1024 * 2) : string{
return zlib_decode($payload, 1024 * 1024 * 64); //Max 64MB return zlib_decode($payload, $maxDecodedLength);
} }
/** /**

View File

@ -260,7 +260,11 @@ class NetworkSession{
Timings::$playerNetworkReceiveDecompressTimer->stopTiming(); Timings::$playerNetworkReceiveDecompressTimer->stopTiming();
} }
$count = 0;
while(!$stream->feof() and $this->connected){ while(!$stream->feof() and $this->connected){
if($count++ >= 500){
throw new BadPacketException("Too many packets in a single batch");
}
try{ try{
$pk = PacketPool::getPacket($stream->getString()); $pk = PacketPool::getPacket($stream->getString());
}catch(BinaryDataException $e){ }catch(BinaryDataException $e){