2016-12-17 04:13:45 +00:00
From 0af5380a6a18ec3d7c06e7fb4501909b55d2da7b Mon Sep 17 00:00:00 2001
2016-03-27 02:38:36 +00:00
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
2016-11-17 02:23:38 +00:00
index 1852972..93b65cd 100644
2016-03-27 02:38:36 +00:00
--- a/src/main/java/net/minecraft/server/BlockPosition.java
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
2016-11-17 02:23:38 +00:00
@@ -158,15 +158,17 @@ public class BlockPosition extends BaseBlockPosition {
2016-03-27 02:38:36 +00:00
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()) {
2016-11-17 02:23:38 +00:00
@@ -177,6 +179,18 @@ public class BlockPosition extends BaseBlockPosition {
2016-03-27 02:38:36 +00:00
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;
2016-11-17 02:23:38 +00:00
@@ -206,15 +220,17 @@ public class BlockPosition extends BaseBlockPosition {
2016-03-27 10:42:02 +00:00
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()) {
2016-11-17 02:23:38 +00:00
@@ -225,6 +241,18 @@ public class BlockPosition extends BaseBlockPosition {
2016-03-27 10:42:02 +00:00
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
2016-05-12 02:07:46 +00:00
this.b.b = i;
this.b.c = j;
2016-03-27 02:38:36 +00:00
--
2016-12-10 23:50:31 +00:00
2.9.3
2016-03-27 02:38:36 +00:00