mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
Fix chunk range int overflow
This commit is contained in:
parent
68ee3947db
commit
a6ae1cc540
1 changed files with 25 additions and 0 deletions
25
patches/server/Fix-int-overflow-in-chunk-range-check.patch
Normal file
25
patches/server/Fix-int-overflow-in-chunk-range-check.patch
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Nassim Jahnke <nassim@njahnke.dev>
|
||||||
|
Date: Tue, 11 Jan 2022 19:31:46 +0100
|
||||||
|
Subject: [PATCH] Fix int overflow in chunk range check
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
|
public static boolean isChunkInRange(int x1, int z1, int x2, int z2, int distance) {
|
||||||
|
int j1 = Math.max(0, Math.abs(x1 - x2) - 1);
|
||||||
|
int k1 = Math.max(0, Math.abs(z1 - z2) - 1);
|
||||||
|
- int l1 = Math.max(0, Math.max(j1, k1) - 1);
|
||||||
|
- int i2 = Math.min(j1, k1);
|
||||||
|
- int j2 = i2 * i2 + l1 * l1;
|
||||||
|
+ // Paper start - fix integer overflow
|
||||||
|
+ long l1 = Math.max(0, Math.max(j1, k1) - 1);
|
||||||
|
+ long i2 = Math.min(j1, k1);
|
||||||
|
+ long j2 = i2 * i2 + l1 * l1;
|
||||||
|
+ // Paper end
|
||||||
|
int k2 = distance - 1;
|
||||||
|
int l2 = k2 * k2;
|
||||||
|
|
Loading…
Reference in a new issue