mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Merge pull request from GHSA-c6fg-99pr-25m9
* Skin: impose length limits on skinID, geometryName and geometryData fields * Skin: remove extra newline
This commit is contained in:
parent
68f3399cfd
commit
958a9dbf0f
@ -28,6 +28,7 @@ use function implode;
|
||||
use function in_array;
|
||||
use function json_encode;
|
||||
use function strlen;
|
||||
use const INT32_MAX;
|
||||
|
||||
class Skin{
|
||||
public const ACCEPTED_SKIN_SIZES = [
|
||||
@ -67,10 +68,20 @@ class Skin{
|
||||
}
|
||||
}
|
||||
|
||||
private static function checkLength(string $string, string $name, int $maxLength) : void{
|
||||
if(strlen($string) > $maxLength){
|
||||
throw new InvalidSkinException("$name must be at most $maxLength bytes, but have " . strlen($string) . " bytes");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidSkinException
|
||||
*/
|
||||
public function validate() : void{
|
||||
self::checkLength($this->skinId, "Skin ID", 32767);
|
||||
self::checkLength($this->geometryName, "Geometry name", 32767);
|
||||
self::checkLength($this->geometryData, "Geometry data", INT32_MAX);
|
||||
|
||||
if($this->skinId === ""){
|
||||
throw new InvalidSkinException("Skin ID must not be empty");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user