aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches
diff options
context:
space:
mode:
authorBjarne Koll <[email protected]>2024-05-12 17:41:21 +0200
committerGitHub <[email protected]>2024-05-12 17:41:21 +0200
commitf041f48458e6d81a54895e988867c0b738922d4d (patch)
treeb926399e0036640aadd1f10a73fa7d27ec2c6b55 /patches
parent7e48f66c05dcc85f8533c96b29fc90b87be65a66 (diff)
downloadPaper-f041f48458e6d81a54895e988867c0b738922d4d.tar.gz
Paper-f041f48458e6d81a54895e988867c0b738922d4d.zip
Prevent infinite recursion on cyclic brig redirect (#10705)
Prevent infinite recursion when declaring a cyclic relation between command nodes via child nodes redirecting to an nth parent by marking a command node as unwrapped before unwrapping its children.
Diffstat (limited to 'patches')
-rw-r--r--patches/server/1048-Brigadier-based-command-API.patch11
1 files changed, 6 insertions, 5 deletions
diff --git a/patches/server/1048-Brigadier-based-command-API.patch b/patches/server/1048-Brigadier-based-command-API.patch
index e99486deda..b3aa5f1dc0 100644
--- a/patches/server/1048-Brigadier-based-command-API.patch
+++ b/patches/server/1048-Brigadier-based-command-API.patch
@@ -251,10 +251,10 @@ index dd6012b6a097575b2d1471be5069eccee4537c0a..00000000000000000000000000000000
-}
diff --git a/src/main/java/io/papermc/paper/command/brigadier/ApiMirrorRootNode.java b/src/main/java/io/papermc/paper/command/brigadier/ApiMirrorRootNode.java
new file mode 100644
-index 0000000000000000000000000000000000000000..2b1cf02f32506187ed0783ae4732ae0f0bdbfc0e
+index 0000000000000000000000000000000000000000..23525592d880f340745a28c956fa38d3e4057231
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/brigadier/ApiMirrorRootNode.java
-@@ -0,0 +1,252 @@
+@@ -0,0 +1,253 @@
+package io.papermc.paper.command.brigadier;
+
+import com.google.common.collect.Collections2;
@@ -401,6 +401,10 @@ index 0000000000000000000000000000000000000000..2b1cf02f32506187ed0783ae4732ae0f
+ throw new IllegalArgumentException("Unknown command node passed. Don't know how to unwrap this.");
+ }
+
++ // Store unwrapped node before unwrapping children to avoid infinite recursion in cyclic redirects.
++ converted.wrappedCached = pureNode;
++ pureNode.unwrappedCached = converted;
++
+ /*
+ Add the children to the node, unwrapping each child in the process.
+ */
@@ -408,9 +412,6 @@ index 0000000000000000000000000000000000000000..2b1cf02f32506187ed0783ae4732ae0f
+ converted.addChild(this.unwrapNode(child));
+ }
+
-+ converted.wrappedCached = pureNode;
-+ pureNode.unwrappedCached = converted;
-+
+ return converted;
+ }
+