mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
core/types/bal: fix off-by-one in balance change index bounds check
The balance change index validation used > blockTxCount+2 which allowed index blockTxCount+2 (out of bounds). Changed to >= to match the nonce, code, and storage change checks. Valid BAL indices are 0..blockTxCount+1. Index blockTxCount+2 is beyond the system transaction index and must be rejected. Found by test_bal_invalid_extraneous_entries[out_of_bounds-extra_balance] in bal@v5.5.1 fixtures.
This commit is contained in:
parent
0253db6ce5
commit
076a330416
1 changed files with 1 additions and 1 deletions
|
|
@ -367,7 +367,7 @@ func (e *AccountAccess) validate(blockTxCount int) error {
|
||||||
return errors.New("balance changes not in ascending order by tx index")
|
return errors.New("balance changes not in ascending order by tx index")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(e.BalanceChanges) > 0 && int(e.BalanceChanges[len(e.BalanceChanges)-1].TxIdx) > blockTxCount+2 {
|
if len(e.BalanceChanges) > 0 && int(e.BalanceChanges[len(e.BalanceChanges)-1].TxIdx) >= blockTxCount+2 {
|
||||||
return errors.New("highest balance change index beyond what is allowed")
|
return errors.New("highest balance change index beyond what is allowed")
|
||||||
}
|
}
|
||||||
// check that the balance values are set and there are no duplicate index entries
|
// check that the balance values are set and there are no duplicate index entries
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue