From 6e248d5fcfb5a3e93475161bf0b2667d71af58c4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 5 Feb 2023 11:13:25 +0700 Subject: [PATCH] =?UTF-8?q?=D1=83=D1=81=D0=BA=D0=BE=D1=80=D1=8F=D0=B5?= =?UTF-8?q?=D0=BC=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=BD?= =?UTF-8?q?=D0=B4=D0=B5=D0=BA=D1=81=D0=BE=D0=B2=20pak=20=D0=B2=D0=B4=D0=B2?= =?UTF-8?q?=D0=BE=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/ru/dbotthepony/kstarbound/io/StarboundPak.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/io/StarboundPak.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/io/StarboundPak.kt index 9d4a5716..2a90f9fa 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/io/StarboundPak.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/io/StarboundPak.kt @@ -194,6 +194,7 @@ class StarboundPak(val path: File, callback: (finished: Boolean, status: String) // long (offset от начала файла) // long (длина файла) val stream = DataInputStream(BufferedInputStream(Channels.newInputStream(reader.channel), 2 shl 22)) + val flength = reader.length() for (i in 0 until indexNodeCount) { var name: String? = null @@ -207,11 +208,11 @@ class StarboundPak(val path: File, callback: (finished: Boolean, status: String) val offset = stream.readLong() val length = stream.readLong() - if (offset > reader.length()) { + if (offset > flength) { throw IndexOutOfBoundsException("Garbage offset at index $i: ${offset}") } - if (length + offset > reader.length()) { + if (length + offset > flength) { throw IndexOutOfBoundsException("Garbage offset + length at index $i: ${length + offset}") }