Function cargo::sources::registry::max_unpack_size

source ·
fn max_unpack_size(gctx: &GlobalContext, size: u64) -> u64
Expand description

Get the maximum unpack size that Cargo permits based on a given size of your compressed file.

Returns the larger one between size * max compression ratio and a fixed max unpacked size.

In reality, the compression ratio usually falls in the range of 2:1 to 10:1. We choose 20:1 to cover almost all possible cases hopefully. Any ratio higher than this is considered as a zip bomb.

In the future we might want to introduce a configurable size.

Some of the real world data from common compression algorithms: