cosmos / iavl

Merkleized IAVL+ Tree implementation in Go
Apache License 2.0
417 stars 263 forks source link

Missing bounds check in deltaEncode #766

Closed elias-orijtech closed 1 year ago

elias-orijtech commented 1 year ago

The value n is only checked for negative values but not for values greater than len(n).

https://github.com/cosmos/iavl/blob/747bc123a38b5803b470fb0faa649207a6c2d739/compress.go#L106-L111

if, on the other hand,deltaEncode should never fail because input is trusted then it shouldn't return an error.

CC @odeke-em

elias-orijtech commented 1 year ago

Nevermind, misunderstood the code.