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

Function WithDecoderMaxMemory

zstd/decoder_options.go:90–101  ·  view source on GitHub ↗

WithDecoderMaxMemory allows to set a maximum decoded size for in-memory non-streaming operations or maximum window size for streaming operations. This can be used to control memory usage of potentially hostile content. Maximum is 1 << 63 bytes. Default is 64GiB. Can be changed with ResetWithOptions.

(n uint64)

Source from the content-addressed store, hash-verified

88// Maximum is 1 << 63 bytes. Default is 64GiB.
89// Can be changed with ResetWithOptions.
90func WithDecoderMaxMemory(n uint64) DOption {
91 return func(o *decoderOptions) error {
92 if n == 0 {
93 return errors.New("WithDecoderMaxMemory must be at least 1")
94 }
95 if n > 1<<63 {
96 return errors.New("WithDecoderMaxmemory must be less than 1 << 63")
97 }
98 o.maxDecodedSize = n
99 return nil
100 }
101}
102
103// WithDecoderDicts allows to register one or more dictionaries for the decoder.
104//

Callers 10

FuzzDecodeAllFunction · 0.85
FuzzDecoderFunction · 0.85
FuzzEncodingFunction · 0.85
DecodeToFunction · 0.85
TestNewDecoderBadFunction · 0.85
TestDecoderRegressionFunction · 0.85

Calls

no outgoing calls

Tested by 9

FuzzDecodeAllFunction · 0.68
FuzzDecoderFunction · 0.68
FuzzEncodingFunction · 0.68
TestNewDecoderBadFunction · 0.68
TestDecoderRegressionFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…