mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
add some limits on batches
This commit is contained in:
parent
2ef3962028
commit
76c234e4e6
@ -61,7 +61,7 @@ class BatchPacket extends DataPacket{
|
||||
protected function decodePayload(){
|
||||
$data = $this->getRemaining();
|
||||
try{
|
||||
$this->payload = zlib_decode($data, 1024 * 1024 * 64); //Max 64MB
|
||||
$this->payload = zlib_decode($data, 1024 * 1024 * 2); //Max 64MB
|
||||
}catch(\ErrorException $e){ //zlib decode error
|
||||
$this->payload = "";
|
||||
}
|
||||
@ -94,7 +94,11 @@ class BatchPacket extends DataPacket{
|
||||
*/
|
||||
public function getPackets(){
|
||||
$stream = new NetworkBinaryStream($this->payload);
|
||||
$count = 0;
|
||||
while(!$stream->feof()){
|
||||
if($count++ >= 500){
|
||||
throw new \UnexpectedValueException("Too many packets in a single batch");
|
||||
}
|
||||
yield $stream->getString();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user