From 68a6d7c76c514ea4ff4fb465b34c72607d3e15ab Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 27 Aug 2023 15:16:53 +0100 Subject: [PATCH] Add expected/actual lengths to Js5Compression error messages Signed-off-by: Graham --- .../main/kotlin/org/openrs2/cache/Js5Compression.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cache/src/main/kotlin/org/openrs2/cache/Js5Compression.kt b/cache/src/main/kotlin/org/openrs2/cache/Js5Compression.kt index f2c2643e..b4d82cf5 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/Js5Compression.kt +++ b/cache/src/main/kotlin/org/openrs2/cache/Js5Compression.kt @@ -187,8 +187,9 @@ public object Js5Compression { } if (type == Js5CompressionType.UNCOMPRESSED) { - if (input.readableBytes() < len) { - throw IOException("Data truncated") + val n = input.readableBytes() + if (n < len) { + throw IOException("Data truncated ($n bytes, expecting $len)") } /* @@ -213,8 +214,9 @@ public object Js5Compression { } val lenWithUncompressedLen = len + 4 - if (input.readableBytes() < lenWithUncompressedLen) { - throw IOException("Compressed data truncated") + val n = input.readableBytes() + if (n < lenWithUncompressedLen) { + throw IOException("Compressed data truncated ($n bytes, expecting $lenWithUncompressedLen)") } /*