mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 04:38:35 +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(){
|
protected function decodePayload(){
|
||||||
$data = $this->getRemaining();
|
$data = $this->getRemaining();
|
||||||
try{
|
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
|
}catch(\ErrorException $e){ //zlib decode error
|
||||||
$this->payload = "";
|
$this->payload = "";
|
||||||
}
|
}
|
||||||
@ -94,7 +94,11 @@ class BatchPacket extends DataPacket{
|
|||||||
*/
|
*/
|
||||||
public function getPackets(){
|
public function getPackets(){
|
||||||
$stream = new NetworkBinaryStream($this->payload);
|
$stream = new NetworkBinaryStream($this->payload);
|
||||||
|
$count = 0;
|
||||||
while(!$stream->feof()){
|
while(!$stream->feof()){
|
||||||
|
if($count++ >= 500){
|
||||||
|
throw new \UnexpectedValueException("Too many packets in a single batch");
|
||||||
|
}
|
||||||
yield $stream->getString();
|
yield $stream->getString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user