mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 00:39:26 +00:00
triedb/pathdb: fix index out of range panic in decodeSingle (#32937)
Fixes TestCorruptedKeySection flaky test failure. https://github.com/ethereum/go-ethereum/actions/runs/18600235182/job/53037084761?pr=32920
This commit is contained in:
parent
88576c52e2
commit
11c0fb98af
1 changed files with 8 additions and 4 deletions
|
|
@ -370,11 +370,15 @@ func decodeSingle(keySection []byte, onValue func([]byte, int, int) error) ([]st
|
||||||
for keyOff < keyLimit {
|
for keyOff < keyLimit {
|
||||||
// Validate the key and value offsets within the single trie data chunk
|
// Validate the key and value offsets within the single trie data chunk
|
||||||
if items%trienodeDataBlockRestartLen == 0 {
|
if items%trienodeDataBlockRestartLen == 0 {
|
||||||
if keyOff != int(keyOffsets[items/trienodeDataBlockRestartLen]) {
|
restartIndex := items / trienodeDataBlockRestartLen
|
||||||
return nil, fmt.Errorf("key offset is not matched, recorded: %d, want: %d", keyOffsets[items/trienodeDataBlockRestartLen], keyOff)
|
if restartIndex >= len(keyOffsets) {
|
||||||
|
return nil, fmt.Errorf("restart index out of range: %d, available restarts: %d", restartIndex, len(keyOffsets))
|
||||||
}
|
}
|
||||||
if valOff != int(valOffsets[items/trienodeDataBlockRestartLen]) {
|
if keyOff != int(keyOffsets[restartIndex]) {
|
||||||
return nil, fmt.Errorf("value offset is not matched, recorded: %d, want: %d", valOffsets[items/trienodeDataBlockRestartLen], valOff)
|
return nil, fmt.Errorf("key offset is not matched, recorded: %d, want: %d", keyOffsets[restartIndex], keyOff)
|
||||||
|
}
|
||||||
|
if valOff != int(valOffsets[restartIndex]) {
|
||||||
|
return nil, fmt.Errorf("value offset is not matched, recorded: %d, want: %d", valOffsets[restartIndex], valOff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Resolve the entry from key section
|
// Resolve the entry from key section
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue