Pocketmine-mp: Corrupted Player UUIDs

Created on 12 Aug 2017  路  6Comments  路  Source: pmmp/PocketMine-MP

Issue description




During the coding of a plugin, I wanted to check whether the UUID of a player to string, and the UUID given in the LoginPacket were similar, in order to execute more code, but found out this doesn't work a lot of the times. These two UUIDs differ for a very small bit, causing them not to be equal.

Steps to reproduce the issue

  1. On player join, save the player unique ID in a property.
  2. Let a player join.
  3. Let the player leave again.
  4. Listen for LoginPacket in DataPacketReceiveEvent, and check if the clientUUID property is equal to the UUID stored in the plugin's property toString().

Following these steps, you sometimes happen to get a correct UUID, while other times you get a result resembling something like below.

OS and versions

  • PocketMine-MP: 02cbf800d0f35f1e54b8a677fb82ee968b9ddc92 (affects all branches and recent versions)
  • PHP: 7.0
  • Server OS: Any
  • Game version: PE (Likely W10 too, not tested)

Plugins

  • Test on a clean server without plugins: is the issue reproducible without any plugins loaded?
    This issue is not reproducible without any plugins loaded, as this issue isn't detectable that way.

Variable dump results

  • Join UUID toString(): "ab186c15-62dd-36cb-899e-9c810c6a3ba9"
  • LoginPacket UUID: "ab186c15-62dd-36cb-b99e-9c810c6a3ba9"

As you can see in those two UUIDs, they're almost 100% identical, except for the -899e/b99e- part.

API Core Fixed

All 6 comments

How is this even possible? Since the UUID is set from the login packet...

I think the issue is an oversimplification of UUID variant validity. The character which switched to an 8 there may be any of 8, 9, A, or B in a valid RFC 4122 UUID. The UUID implementation as a whole lacks the real meat of a UUID implementation.

Regardless, you'd be wiser to store the UUID in its raw form (toBinary()) and compare the binary forms, instead of using the string representation.

You have to use toString() though, if you're comparing it against the LoginPacket UUID.

$uuid = UUID::fromString($packet->clientUUID)->toBinary();
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dktapps picture dktapps  路  3Comments

beetree picture beetree  路  3Comments

Hugheth picture Hugheth  路  3Comments

Ox531 picture Ox531  路  3Comments

RedstoneAlmeida picture RedstoneAlmeida  路  3Comments