From f3d4ce0d164f7b17a143304e2b94421573d596a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 20 Jan 2016 16:06:28 +0200 Subject: core/state, ethdb, trie: test intermediate secure key leak, fix memdb bug --- trie/secure_trie.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'trie') 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 -- cgit v1.2.3