Compress: limit patternMaxDepth (#598)

* save

* save

* save

* save

* save

* save
This commit is contained in:
Alex Sharov 2022-08-22 13:04:01 +07:00 committed by GitHub
parent 36778a2db3
commit 09dba54e27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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