pub const fn zstd_window_log_max(max_decompressed_size: usize) -> Option<u32>Expand description
Smallest zstd window_log_max capable of representing max_decompressed_size bytes.
zstd frames declare a window size that the decoder must allocate up front; a crafted frame can
request a multi-gigabyte window even though its output would later trip the decompressed-size
cap. Clamping the decoder’s window_log_max to the smallest power-of-two window that can still
hold a legitimate payload bounds that allocation. A zero cap maps to the minimum window log
(not None) so the guard stays at its strictest rather than being disabled.
This is protocol-neutral: the ceiling is derived from the decompressed cap so any transport’s
frames decode as long as their window fits the cap. Transports that impose a tighter,
spec-mandated window (HTTP Content-Encoding: zstd, see http_zstd_window_log_max) apply
that on top.