mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-13 07:23:46 +00:00
trie: don't crash for invalid proof (needs investigation)
This commit is contained in:
parent
cc860e38e5
commit
df0056c1dc
1 changed files with 3 additions and 2 deletions
|
|
@ -125,7 +125,7 @@ func VerifyProof(rootHash common.Hash, key []byte, proof []rlp.RawValue) (value
|
||||||
}
|
}
|
||||||
|
|
||||||
func get(tn node, key []byte) ([]byte, node) {
|
func get(tn node, key []byte) ([]byte, node) {
|
||||||
for len(key) > 0 {
|
for {
|
||||||
switch n := tn.(type) {
|
switch n := tn.(type) {
|
||||||
case *shortNode:
|
case *shortNode:
|
||||||
if len(key) < len(n.Key) || !bytes.Equal(n.Key, key[:len(n.Key)]) {
|
if len(key) < len(n.Key) || !bytes.Equal(n.Key, key[:len(n.Key)]) {
|
||||||
|
|
@ -140,9 +140,10 @@ func get(tn node, key []byte) ([]byte, node) {
|
||||||
return key, n
|
return key, n
|
||||||
case nil:
|
case nil:
|
||||||
return key, nil
|
return key, nil
|
||||||
|
case valueNode:
|
||||||
|
return nil, n
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("%T: invalid node: %v", tn, tn))
|
panic(fmt.Sprintf("%T: invalid node: %v", tn, tn))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, tn.(valueNode)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue