From bca489922ad63357a2ab4f46d33f1ea3adc88950 Mon Sep 17 00:00:00 2001 From: Querz Date: Fri, 9 Jun 2023 14:10:54 +0200 Subject: [PATCH] fix byte overflow when defragmenting chunks with more than 520KB of data --- src/main/java/net/querz/mcaselector/io/mca/MCAFile.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/querz/mcaselector/io/mca/MCAFile.java b/src/main/java/net/querz/mcaselector/io/mca/MCAFile.java index 85e6fd71..dfd278f2 100644 --- a/src/main/java/net/querz/mcaselector/io/mca/MCAFile.java +++ b/src/main/java/net/querz/mcaselector/io/mca/MCAFile.java @@ -156,12 +156,12 @@ public void deFragment(File dest) throws IOException { // loop over all offsets, readHeader the raw byte data (complete sections) and write it to new file for (int i = 0; i < offsets.length; i++) { // don't do anything if this chunk is empty - if (offsets[i] == 0 || sectors[i] <= 0) { + if (offsets[i] == 0 || sectors[i] == 0) { skippedChunks++; continue; } - int sectors = this.sectors[i]; + int sectors = this.sectors[i] & 0xFF; // write offset and sector size to tmp file rafTmp.seek(i * 4L);