MCPcopy
hub / github.com/klauspost/compress / WithDecoderMaxWindow

Function WithDecoderMaxWindow

zstd/decoder_options.go:150–161  ·  view source on GitHub ↗

WithDecoderMaxWindow allows to set a maximum window size for decodes. This allows rejecting packets that will cause big memory usage. The Decoder will likely allocate more memory based on the WithDecoderLowmem setting. If WithDecoderMaxMemory is set to a lower value, that will be used. Default is 51

(size uint64)

Source from the content-addressed store, hash-verified

148// Default is 512MB, Maximum is ~3.75 TB as per zstandard spec.
149// Can be changed with ResetWithOptions.
150func WithDecoderMaxWindow(size uint64) DOption {
151 return func(o *decoderOptions) error {
152 if size < MinWindowSize {
153 return errors.New("WithMaxWindowSize must be at least 1KB, 1024 bytes")
154 }
155 if size > (1<<41)+7*(1<<38) {
156 return errors.New("WithMaxWindowSize must be less than (1<<41) + 7*(1<<38) ~ 3.75TB")
157 }
158 o.maxWindowSize = size
159 return nil
160 }
161}
162
163// WithDecodeAllCapLimit will limit DecodeAll to decoding cap(dst)-len(dst) bytes,
164// or any size set in WithDecoderMaxMemory.

Callers 9

ReadMethod · 0.92
FuzzDecodeAllFunction · 0.85
FuzzDecoderFunction · 0.85
FuzzEncodingFunction · 0.85
TestNewDecoderFrameSizeFunction · 0.85
zip.goFile · 0.85
newZipReaderFunction · 0.85

Calls

no outgoing calls

Tested by 6

FuzzDecodeAllFunction · 0.68
FuzzDecoderFunction · 0.68
FuzzEncodingFunction · 0.68
TestNewDecoderFrameSizeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…