Added skin checks to Player and Human

This commit is contained in:
Shoghi Cervantes 2015-04-09 20:58:38 +02:00
parent 0aa9586a52
commit 73d1d131e1
2 changed files with 9 additions and 1 deletions

View File

@ -1340,6 +1340,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->nameTag = $this->username;
$this->iusername = strtolower($this->username);
$this->randomClientId = $packet->clientId;
if(strlen($packet->skin) < 64 * 32 * 4){
$this->close("", "Invalid skin", false);
return;
}
$this->setSkin($packet->skin, $packet->slim);
$this->loginData = ["clientId" => $packet->clientId, "loginData" => null];

View File

@ -33,7 +33,6 @@ use pocketmine\Network;
use pocketmine\network\protocol\AddPlayerPacket;
use pocketmine\network\protocol\RemovePlayerPacket;
use pocketmine\Player;
use pocketmine\utils\TextFormat;
class Human extends Creature implements ProjectileSource, InventoryHolder{
@ -186,6 +185,10 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
if($player !== $this and !isset($this->hasSpawned[$player->getId()])){
$this->hasSpawned[$player->getId()] = $player;
if(strlen($this->skin) < 64 * 32 * 4){
throw new \InvalidStateException((new \ReflectionClass($this))->getShortName() . " must have a valid skin set");
}
$pk = new AddPlayerPacket();
$pk->clientID = 0;
$pk->username = $this->nameTag;