aboutsummaryrefslogtreecommitdiffstats
path: root/trie
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-01-20 22:06:28 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-01-20 22:06:28 +0800
commitf3d4ce0d164f7b17a143304e2b94421573d596a4 (patch)
tree9c4dab5e403b3c71cc1a95c59b23cf8bba1bc0ba /trie
parent886478b18b73bbe8421531f1a71664a2bc0f5eeb (diff)
downloadgo-tangerine-f3d4ce0d164f7b17a143304e2b94421573d596a4.tar.gz
go-tangerine-f3d4ce0d164f7b17a143304e2b94421573d596a4.tar.zst
go-tangerine-f3d4ce0d164f7b17a143304e2b94421573d596a4.zip
core/state, ethdb, trie: test intermediate secure key leak, fix memdb bug
Diffstat (limited to 'trie')
-rw-r--r--trie/secure_trie.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/trie/secure_trie.go b/trie/secure_trie.go
index ca515aacb..be7defe83 100644
--- a/trie/secure_trie.go
+++ b/trie/secure_trie.go
@@ -109,7 +109,7 @@ func (t *SecureTrie) TryUpdate(key, value []byte) error {
if err != nil {
return err
}
- t.secKeyCache[string(hk)] = key
+ t.secKeyCache[string(hk)] = common.CopyBytes(key)
return nil
}
@@ -123,7 +123,9 @@ func (t *SecureTrie) Delete(key []byte) {
// TryDelete removes any existing value for key from the trie.
// If a node was not found in the database, a MissingNodeError is returned.
func (t *SecureTrie) TryDelete(key []byte) error {
- return t.Trie.TryDelete(t.hashKey(key))
+ hk := t.hashKey(key)
+ delete(t.secKeyCache, string(hk))
+ return t.Trie.TryDelete(hk)
}
// GetKey returns the sha3 preimage of a hashed key that was