mpt: disallow empty keys
This is not a problem in practice, as all keys are prefixed by a contract ID. However in theory it can lead to a different state root after new portion of changes thus this fix.
This commit is contained in:
parent
5b1f6207de
commit
e833d333fe
3 changed files with 16 additions and 15 deletions
|
@ -97,7 +97,9 @@ func (t *Trie) getWithPath(curr Node, path []byte) (Node, []byte, error) {
|
|||
|
||||
// Put puts key-value pair in t.
|
||||
func (t *Trie) Put(key, value []byte) error {
|
||||
if len(key) > MaxKeyLength {
|
||||
if len(key) == 0 {
|
||||
return errors.New("key is empty")
|
||||
} else if len(key) > MaxKeyLength {
|
||||
return errors.New("key is too big")
|
||||
} else if len(value) > MaxValueLength {
|
||||
return errors.New("value is too big")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue