ArchiveLimits

data class ArchiveLimits(val maxUncompressedBytes: Long = 2L * 1024 * 1024 * 1024, val maxCompressionRatio: Int, val maxEntries: Int, val maxNestingDepth: Int = 8)

Decompression-bomb defences, applied during decode (never trust a declared size for allocation). Passed into every decompress/read call; the defaults are deliberately safe so a caller cannot forget them.

See the classic 42.zip (42 KB → 4.5 PB) and Fifield's non-recursive overlapping bombs (~10 MB → 281 TB in one pass). The only universal defence is a hard cap on bytes written, which checkOutputSize enforces.

Constructors

Link copied to clipboard
constructor(maxUncompressedBytes: Long = 2L * 1024 * 1024 * 1024, maxCompressionRatio: Int, maxEntries: Int, maxNestingDepth: Int = 8)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Per-entry compression-ratio ceiling. Default 10000:1.

Link copied to clipboard

Maximum number of entries in a container. Default 100k.

Link copied to clipboard

Maximum auto-extract nesting depth (archive-in-archive). Default 8.

Link copied to clipboard

Hard ceiling on total uncompressed bytes produced. Default 2 GiB.

Functions

Link copied to clipboard
fun checkEntryCount(count: Int)
Link copied to clipboard
fun checkOutputSize(bytes: Long)
Link copied to clipboard
fun checkRatio(compressedBytes: Long, uncompressedBytes: Long)