add some limits on batches

This commit is contained in:
Dylan K. Taylor 2019-04-21 14:15:38 +01:00
parent 2ef3962028
commit 76c234e4e6

View File

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