From df0056c1dc314b69b01874dfc04a3e670a58d42d Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 15 Jun 2017 19:07:41 +0200 Subject: [PATCH] trie: don't crash for invalid proof (needs investigation) --- trie/proof.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/trie/proof.go b/trie/proof.go index 1f8f76b1b7..298f648c4b 100644 --- a/trie/proof.go +++ b/trie/proof.go @@ -125,7 +125,7 @@ func VerifyProof(rootHash common.Hash, key []byte, proof []rlp.RawValue) (value } func get(tn node, key []byte) ([]byte, node) { - for len(key) > 0 { + for { switch n := tn.(type) { case *shortNode: 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 case nil: return key, nil + case valueNode: + return nil, n default: panic(fmt.Sprintf("%T: invalid node: %v", tn, tn)) } } - return nil, tn.(valueNode) }