komp_decompress: Decompress a raw vector

View source: R/decompress.R

komp_decompressR Documentation

Decompress a raw vector

Description

Decompress a raw vector

Usage

komp_decompress(
  x,
  codec = "auto",
  max_output = getOption("zukomp.max_output", 1024^3),
  max_ratio = getOption("zukomp.max_ratio", NULL)
)

Arguments

x

A raw vector holding a complete compressed stream.

codec

Codec name, as listed in komp_codecs().

max_output

Refuse to produce more than this many bytes. Defaults to 1 GiB, overridable with options(zukomp.max_output = ). Use 0 for unlimited, deliberately. Compressed input from an untrusted source can expand enormously, and the cap is enforced by the core stream driver, so no codec can bypass it.

max_ratio

Refuse to expand by more than this factor. NULL (the default) means no ratio limit: legitimately compressible data routinely exceeds any safe-looking threshold, so this is opt-in.

Value

A raw vector.

See Also

komp_compress(), komp_codecs()

Examples

z <- komp_compress(charToRaw(strrep("data ", 200)), "gzip")
rawToChar(komp_decompress(z, "gzip"))

# a small input that would expand a long way is stopped, not allocated
bomb <- komp_compress(raw(1e6), "gzip")
length(bomb)
try(komp_decompress(bomb, "gzip", max_output = 1024))

zukomp documentation built on Oct. 16, 2026, 5:09 p.m.