mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
fix(bintrie): prevent OOB on 31-byte stems at depth 248
This commit is contained in:
parent
da3822dcec
commit
391f3bea5c
2 changed files with 7 additions and 1 deletions
|
|
@ -47,6 +47,9 @@ func (h HashedNode) GetValuesAtStem(_ []byte, _ NodeResolverFn) ([][]byte, error
|
|||
}
|
||||
|
||||
func (h HashedNode) InsertValuesAtStem(stem []byte, values [][]byte, resolver NodeResolverFn, depth int) (BinaryNode, error) {
|
||||
if depth >= StemSize*8 {
|
||||
return nil, errors.New("InsertValuesAtStem resolve error: node too deep")
|
||||
}
|
||||
// Step 1: Generate the path for this node's position in the tree
|
||||
path, err := keyToPath(depth, stem)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ type InternalNode struct {
|
|||
|
||||
// GetValuesAtStem retrieves the group of values located at the given stem key.
|
||||
func (bt *InternalNode) GetValuesAtStem(stem []byte, resolver NodeResolverFn) ([][]byte, error) {
|
||||
if bt.depth > 31*8 {
|
||||
if bt.depth >= StemSize*8 {
|
||||
return nil, errors.New("node too deep")
|
||||
}
|
||||
|
||||
|
|
@ -134,6 +134,9 @@ func (bt *InternalNode) Hash() common.Hash {
|
|||
// Already-existing values will be overwritten.
|
||||
func (bt *InternalNode) InsertValuesAtStem(stem []byte, values [][]byte, resolver NodeResolverFn, depth int) (BinaryNode, error) {
|
||||
var err error
|
||||
if bt.depth >= StemSize*8 {
|
||||
return nil, errors.New("node too deep")
|
||||
}
|
||||
bit := stem[bt.depth/8] >> (7 - (bt.depth % 8)) & 1
|
||||
if bit == 0 {
|
||||
if bt.left == nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue