From 3f0415b45303568fe5d362dc3fa27b3a4ca680eb Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Thu, 11 Aug 2022 14:38:45 +0100 Subject: [PATCH] Use thread safe Random inside of ServerLoginPacketListenerImpl Vanilla uses a Random instance which is not thread safe inside of the constructor for ServerLoginPacketListenerImpl, this is an issue because instances of that class are created on the network worker threads, which means that there is a potential (which we have reports confirming) that multiple users logging on could trip this --- ...random-in-ServerLoginPacketListenerI.patch | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 patches/server/0933-Use-thread-safe-random-in-ServerLoginPacketListenerI.patch diff --git a/patches/server/0933-Use-thread-safe-random-in-ServerLoginPacketListenerI.patch b/patches/server/0933-Use-thread-safe-random-in-ServerLoginPacketListenerI.patch new file mode 100644 index 0000000000..81d6721a69 --- /dev/null +++ b/patches/server/0933-Use-thread-safe-random-in-ServerLoginPacketListenerI.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Thu, 11 Aug 2022 14:37:33 +0100 +Subject: [PATCH] Use thread safe random in ServerLoginPacketListenerImpl + + +diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +index bf488013e45b9ab97568e587f4dad899498b2f73..88a849a21d6e39fd70f6e7b554528da1a5a7dd57 100644 +--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +@@ -52,7 +52,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se + private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0); + static final Logger LOGGER = LogUtils.getLogger(); + private static final int MAX_TICKS_BEFORE_LOGIN = 600; +- private static final RandomSource RANDOM = RandomSource.create(); ++ private static final RandomSource RANDOM = new org.bukkit.craftbukkit.util.RandomSourceWrapper(new java.util.Random()); // Paper - This is called across threads, make safe + private final byte[] nonce; + final MinecraftServer server; + public final Connection connection;