From 977dd0bd93ede3b7528503a9e9ac9b9d9bdb6b9f Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 12 Sep 2020 14:56:56 +0100 Subject: [PATCH] Check that we read exactly uncompressedLen bytes Signed-off-by: Graham --- cache/src/main/java/dev/openrs2/cache/Js5Compression.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cache/src/main/java/dev/openrs2/cache/Js5Compression.kt b/cache/src/main/java/dev/openrs2/cache/Js5Compression.kt index 206018f4..c0bd93e0 100644 --- a/cache/src/main/java/dev/openrs2/cache/Js5Compression.kt +++ b/cache/src/main/java/dev/openrs2/cache/Js5Compression.kt @@ -152,6 +152,10 @@ public object Js5Compression { } remaining -= n } + + if (inputStream.read() != -1) { + throw IOException("Uncompressed data overflow") + } } return output.retain()