Check that there is no trailing data after a group in CacheImporter

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent b067020cad
commit e1f1da1cc0
  1. 10
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt

@ -533,8 +533,14 @@ public class CacheImporter @Inject constructor(
}
}
val uncompressed = Js5Compression.uncompressUnlessEncrypted(buf.slice())
return Group(archive, group, buf.retain(), uncompressed, version, versionTruncated)
val slice = buf.slice()
Js5Compression.uncompressUnlessEncrypted(slice).use { uncompressed ->
if (slice.isReadable) {
throw IOException("Trailing bytes after compressed data")
}
return Group(archive, group, buf.retain(), uncompressed?.retain(), version, versionTruncated)
}
}
} catch (ex: IOException) {
return null

Loading…
Cancel
Save