aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0097-Prevent-possible-infinite-loop-in-BlockPosition-iter.patch
blob: 17e5de424c83077baeeb921ba0e319c13adfa404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
From 8d48ed529554ee9f79b535d4a88f20ac1f9a68e7 Mon Sep 17 00:00:00 2001
From: DemonWav <demonwav@gmail.com>
Date: Sat, 26 Mar 2016 21:36:05 -0500
Subject: [PATCH] Prevent possible infinite loop in BlockPosition iterator


diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
index 704faa9..d6cc51b 100644
--- a/src/main/java/net/minecraft/server/BlockPosition.java
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
@@ -141,15 +141,17 @@ public class BlockPosition extends BaseBlockPosition {
 
                     protected BlockPosition a() {
                         if (this.b == null) {
-                            this.b = blockposition;
+                            this.b = blockposition2; // Paper - use blockposition2 instead of blockposition to prevent infinite loops
                             return this.b;
-                        } else if (this.b.equals(blockposition1)) {
+                        } else if (this.b.equals(blockposition3)) { // Paper - use blockposition3 instead of blockposition1 to prevent infinite loops
                             return (BlockPosition) this.endOfData();
                         } else {
                             int i = this.b.getX();
                             int j = this.b.getY();
                             int k = this.b.getZ();
 
+                            // Paper start - use blockposition2 and blockposition3 to prevent infinite loops
+                            /*
                             if (i < blockposition1.getX()) {
                                 ++i;
                             } else if (j < blockposition1.getY()) {
@@ -160,6 +162,18 @@ public class BlockPosition extends BaseBlockPosition {
                                 j = blockposition.getY();
                                 ++k;
                             }
+                            */
+                            if (i < blockposition3.getX()) {
+                                ++i;
+                            } else if (j < blockposition3.getY()) {
+                                i = blockposition2.getX();
+                                ++j;
+                            } else if (k < blockposition3.getZ()) {
+                                i = blockposition2.getX();
+                                j = blockposition2.getY();
+                                ++k;
+                            }
+                            // Paper end
 
                             this.b = new BlockPosition(i, j, k);
                             return this.b;
@@ -189,15 +203,17 @@ public class BlockPosition extends BaseBlockPosition {
 
                     protected BlockPosition.MutableBlockPosition a() {
                         if (this.b == null) {
-                            this.b = new BlockPosition.MutableBlockPosition(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+                            this.b = new BlockPosition.MutableBlockPosition(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ()); // Paper - use blockposition2 instead of blockposition to prevent infinite loops
                             return this.b;
-                        } else if (this.b.equals(blockposition1)) {
+                        } else if (this.b.equals(blockposition3)) { // Paper - use blockposition3 instead of blockposition1 to prevent infinite loops
                             return (BlockPosition.MutableBlockPosition) this.endOfData();
                         } else {
                             int i = this.b.getX();
                             int j = this.b.getY();
                             int k = this.b.getZ();
 
+                            // Paper start - use blockposition2 and blockposition3 to prevent infinite loops
+                            /*
                             if (i < blockposition1.getX()) {
                                 ++i;
                             } else if (j < blockposition1.getY()) {
@@ -208,6 +224,18 @@ public class BlockPosition extends BaseBlockPosition {
                                 j = blockposition.getY();
                                 ++k;
                             }
+                            */
+                            if (i < blockposition3.getX()) {
+                                ++i;
+                            } else if (j < blockposition3.getY()) {
+                                i = blockposition2.getX();
+                                ++j;
+                            } else if (k < blockposition3.getZ()) {
+                                i = blockposition2.getX();
+                                j = blockposition2.getY();
+                                ++k;
+                            }
+                            // Paper end
 
                             this.b.b = i;
                             this.b.c = j;
-- 
2.9.3