Skip to content

Commit fb20bb3

Browse files
committed
Don't handle NAN/INF in movements
1 parent 3333df3 commit fb20bb3

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/pocketmine/Player.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@
196196
use function gettype;
197197
use function implode;
198198
use function in_array;
199+
use function is_infinite;
199200
use function is_int;
201+
use function is_nan;
200202
use function is_object;
201203
use function is_string;
202204
use function json_encode;
@@ -2357,8 +2359,15 @@ public function chat(string $message) : bool{
23572359
}
23582360

23592361
public function handleMovePlayer(MovePlayerPacket $packet) : bool{
2360-
$newPos = $packet->position->round(4)->subtract(0, $this->baseOffset, 0);
2362+
$rawPos = $packet->position;
2363+
foreach([$rawPos->x, $rawPos->y, $rawPos->z, $packet->yaw, $packet->headYaw, $packet->pitch] as $float){
2364+
if(is_infinite($float) || is_nan($float)){
2365+
$this->server->getLogger()->debug("Invalid movement from " . $this->getName() . ", contains NAN/INF components");
2366+
return false;
2367+
}
2368+
}
23612369

2370+
$newPos = $rawPos->round(4)->subtract(0, $this->baseOffset, 0);
23622371
if($this->forceMoveSync !== null and $newPos->distanceSquared($this->forceMoveSync) > 1){ //Tolerate up to 1 block to avoid problems with client-sided physics when spawning in blocks
23632372
$this->server->getLogger()->debug("Got outdated pre-teleport movement from " . $this->getName() . ", received " . $newPos . ", expected " . $this->asVector3());
23642373
//Still getting movements from before teleport, ignore them

0 commit comments

Comments
 (0)