From 09dba54e27c2f1f409eca6ff6bb5fbd23c8f08fc Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Mon, 22 Aug 2022 13:04:01 +0700 Subject: [PATCH] Compress: limit patternMaxDepth (#598) * save * save * save * save * save * save --- compress/decompress.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compress/decompress.go b/compress/decompress.go index d21ec482c..80773b34c 100644 --- a/compress/decompress.go +++ b/compress/decompress.go @@ -195,6 +195,9 @@ func NewDecompressor(compressedFile string) (*Decompressor, error) { for i < dictSize { d, ns := binary.Uvarint(data[i:]) + if d > 2048 { + return nil, fmt.Errorf("dictionary is invalid: patternMaxDepth=%d", d) + } depths = append(depths, d) if d > patternMaxDepth { patternMaxDepth = d @@ -232,6 +235,9 @@ func NewDecompressor(compressedFile string) (*Decompressor, error) { i = 0 for i < dictSize { d, ns := binary.Uvarint(data[i:]) + if d > 2048 { + return nil, fmt.Errorf("dictionary is invalid: posMaxDepth=%d", d) + } posDepths = append(posDepths, d) if d > posMaxDepth { posMaxDepth = d @@ -241,6 +247,9 @@ func NewDecompressor(compressedFile string) (*Decompressor, error) { i += uint64(n) poss = append(poss, pos) } + if posMaxDepth > 31 { + fmt.Printf("alex: %d\n", posMaxDepth) + } if dictSize > 0 { var bitLen int