Skip to main content

Module limit

Module limit 

Source
Expand description

Decompression-bomb protection.

Two pieces rather than one, because the codec sits between them: Counting wraps the source and tallies compressed bytes going in, and RatioGuard is called by the copy loop with decompressed bytes coming out. Once output outgrows input implausibly, the decode is refused.

Structs§

Counting
A Source that tallies the bytes it has served.
CountingWriter
Counts bytes on their way out, so a caller can report bytes_out correctly even for a destination with no length — stdout, notably.
RatioGuard
Refuses a decode whose output outgrows its input implausibly.

Constants§

DEFAULT_MAX_RATIO
Default expansion ratio past which a decode is refused.
RATIO_FLOOR
Output below which the ratio is not enforced.