From 52263ac3b76332c1ad6795fb0fe82eb8b15de5a8 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Wed, 28 Feb 2018 10:59:00 +1000 Subject: [PATCH] Ignore CUI connections with more than 3 failed attempts. --- .../main/java/com/sk89q/worldedit/LocalSession.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index e7ffcd165..9c04626ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -65,6 +65,7 @@ public class LocalSession { // Non-session related fields private transient LocalConfiguration config; private transient final AtomicBoolean dirty = new AtomicBoolean(); + private transient int failedCuiAttempts = 0; // Session related private transient RegionSelector selector = new CuboidRegionSelector(); @@ -772,14 +773,22 @@ public class LocalSession { */ public void handleCUIInitializationMessage(String text) { checkNotNull(text); + if (this.failedCuiAttempts > 3) { + return; + } - String[] split = text.split("\\|"); + String[] split = text.split("\\|", 2); if (split.length > 1 && split[0].equalsIgnoreCase("v")) { // enough fields and right message + if (split[1].length() > 4) { + this.failedCuiAttempts ++; + return; + } setCUISupport(true); try { setCUIVersion(Integer.parseInt(split[1])); } catch (NumberFormatException e) { WorldEdit.logger.warning("Error while reading CUI init message: " + e.getMessage()); + this.failedCuiAttempts ++; } } }