From 0a1dbbe3c746315af5bc64e6a4cc1afcbc74bbe6 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Mon, 6 Jan 2025 16:29:24 +0100 Subject: [PATCH] Add sanity-check for min/max expected minecraft region coordinates --- .../bluemap/core/world/mca/region/RegionType.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/de/bluecolored/bluemap/core/world/mca/region/RegionType.java b/core/src/main/java/de/bluecolored/bluemap/core/world/mca/region/RegionType.java index 4c68b1f7..fa6792f6 100644 --- a/core/src/main/java/de/bluecolored/bluemap/core/world/mca/region/RegionType.java +++ b/core/src/main/java/de/bluecolored/bluemap/core/world/mca/region/RegionType.java @@ -113,10 +113,17 @@ public String getRegionFileName(int regionX, int regionZ) { public @Nullable Vector2i getRegionFromFileName(String fileName) { Matcher matcher = regionFileNamePattern.matcher(fileName); if (!matcher.matches()) return null; - return new Vector2i( - Integer.parseInt(matcher.group(1)), - Integer.parseInt(matcher.group(2)) - ); + + int regionX = Integer.parseInt(matcher.group(1)); + int regionZ = Integer.parseInt(matcher.group(2)); + + // sanity-check for roughly minecraft max boundaries (-30 000 000 to 30 000 000) + if ( + regionX < -100000 || regionX > 100000 || + regionZ < -100000 || regionZ > 100000 + ) return null; + + return new Vector2i(regionX, regionZ); } }