Protect against \0 attacks on name checking

This commit is contained in:
Shoghi Cervantes 2014-09-20 18:26:17 +02:00
parent b880bf13f8
commit 36d8100e17

View File

@ -1182,7 +1182,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
return; return;
} }
if(preg_match('#^[a-zA-Z0-9_]{3,16}$#', $packet->username) == 0 or $this->username === "" or $this->iusername === "rcon" or $this->iusername === "console" or strlen($packet->username) > 16 or strlen($packet->username) < 3){ if(strpos($packet->username, "\x00") !== false or preg_match('#^[a-zA-Z0-9_]{3,16}$#', $packet->username) == 0 or $this->username === "" or $this->iusername === "rcon" or $this->iusername === "console" or strlen($packet->username) > 16 or strlen($packet->username) < 3){
$this->close("", "Bad username"); $this->close("", "Bad username");
return; return;