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
Sourcethat tallies the bytes it has served. - Counting
Writer - Counts bytes on their way out, so a caller can report
bytes_outcorrectly even for a destination with no length — stdout, notably. - Ratio
Guard - 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.