mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
triedb/pathdb: check result
This commit is contained in:
parent
78ff9911c5
commit
e71031e02f
1 changed files with 9 additions and 0 deletions
|
|
@ -387,10 +387,19 @@ func decodeSingle(keySection []byte, onValue func([]byte, int, int) error) ([]st
|
|||
}
|
||||
// Resolve the entry from key section
|
||||
nShared, nn := binary.Uvarint(keySection[keyOff:]) // key length shared (varint)
|
||||
if nn <= 0 {
|
||||
return nil, fmt.Errorf("corrupted varint encoding for nShared at offset %d", keyOff)
|
||||
}
|
||||
keyOff += nn
|
||||
nUnshared, nn := binary.Uvarint(keySection[keyOff:]) // key length not shared (varint)
|
||||
if nn <= 0 {
|
||||
return nil, fmt.Errorf("corrupted varint encoding for nUnshared at offset %d", keyOff)
|
||||
}
|
||||
keyOff += nn
|
||||
nValue, nn := binary.Uvarint(keySection[keyOff:]) // value length (varint)
|
||||
if nn <= 0 {
|
||||
return nil, fmt.Errorf("corrupted varint encoding for nValue at offset %d", keyOff)
|
||||
}
|
||||
keyOff += nn
|
||||
|
||||
// Validate that the values can fit in an int to prevent overflow on 32-bit systems
|
||||
|
|
|
|||
Loading…
Reference in a new issue