Skip to content

Commit

Permalink
proof: fix panic for keys with all 0xff bytes (#288)
Browse files Browse the repository at this point in the history
Fixes #286. The `cpIncr()` function incorrectly incremented all bytes for values that are all `0xff` before appending `0x00`. In these cases it should keep the original value and append `0x00`.
  • Loading branch information
erikgrinaker committed Sep 25, 2020
1 parent b0666d6 commit 5fab77f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
- [\#312](https://github.com/cosmos/iavl/pull/312) Added `MutableTree.SetInitialVersion()` to
set the initial version after tree initialization.

### Bug Fixes

- [\#288](https://github.com/cosmos/iavl/pull/288) Fix panics when generating proofs for keys that are all `0xFF`.

## 0.14.0 (July 2, 2020)

**Important information:** the pruning functionality introduced with IAVL 0.13.0 via the options
Expand Down
3 changes: 3 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func cpIncr(bz []byte) (ret []byte) {
}
ret[i] = byte(0x00)
if i == 0 {
// here, the original bz is all 0xFF, so we keep the original and append 0x00
// instead of returning all 0x00
ret = cp(bz)
return append(ret, 0x00)
}
}
Expand Down

0 comments on commit 5fab77f

Please sign in to comment.